1

在 Phonegap 中,我需要显示来自使用多个子域的 CDN 的一些图像。例如:

<img src="http://a1.mzstatic.com/.....75.jpg">
<img src="http://a2.mzstatic.com/.....75.jpg">
<img src="http://a3.mzstatic.com/.....75.jpg">
<img src="http://a4.mzstatic.com/.....75.jpg">

因为这些是多个子域上的外部资源,所以我在 config.xml 中设置了以下内容:

<access origin="http://mzstatic.com*" subdomains="true" />

但是,所有图像都显示损坏,就好像它无法调用服务器一样。我补充说:

<access origin="http://a1.mzstatic.com*" />

并且该域上的图像开始工作。

难道我做错了什么?

为了证明这一点并消除所有其他因素,我将 phonegap-start 项目分叉到这里https://github.com/SeanBannister/phonegap-start这证明了我的问题,我刚刚添加了我的图像元素和访问来源配置。

更新CDN 有无限数量的子域,所以我不能全部列出。

4

3 回答 3

2

试一试<access origin="http://*.mzstatic.com" />

于 2013-06-25T16:19:35.400 回答
0

Have you tried mixing what worked for the 1 domain for you:

<access origin="http://a1.mzstatic.com*" />

and the answer @Aguardientico said and did something along the line of....

<access origin="http://*.mzstatic.com*" />

And sorry would have just posted as a comment on @Aguardientico but not enough rep :(

Update 1

After looking at https://build.phonegap.com/docs/config-xml, have you tried:

<access origin="http://*.mzstatic.com*" subdomains="true" /> (Or maybe some variance of the "origin" talked about before)

Update 2

Alright after an hour or two of trying various combination... The option that I was only able to get to work was <access origin="*" /> Naturally though this isn't good practice to allow everything but it seems like it's the only thing that works right now... The PG/Cordova folks really ought to update their documentation on to why it isn't working.

于 2013-06-25T17:29:33.437 回答
-1

你需要试试这个:

<access origin="http://*.mzstatic.com/*" subdomains="true" />

第一个 * 将允许主机/域名之前的任何字符 & 第二个 * 将允许 "/" 之后的任何字符

这应该有效。

于 2017-06-06T09:15:58.333 回答