2016-11-14 39 views
1

我已列入白名单url也在config.xml中添加<access origin="*" />但图像没有显示在混合应用程序。 它显示在浏览器中,但不显示在应用程序中。远程图像不加载在科尔多瓦

我到处搜索,并尝试所有提到的,但它不工作。 但是,本地图像显示正常。

<img width="35" height="30" id="profile-pics" class="profile img-circle" name="profile-pics" src="http://www.example.com/img/53_20160713104002.png"> 

config.xml中

<access origin="*" /> 
    <allow-intent href="http://*/*" /> 
    <allow-navigation href="http://www.test.com/*" /> 
    <allow-navigation href="http://www.example.com/*" /> 
    <allow-intent href="http://*/*" /> 
    <allow-intent href="https://*/*" /> 
    <allow-intent href="tel:*" /> 
    <allow-intent href="sms:*" /> 
    <allow-intent href="mailto:*" /> 
    <allow-intent href="geo:*" /> 
    <platform name="android"> 
     <allow-intent href="market:*" /> 
    </platform> 
+0

它是不显示在iOS,Android或两者?如果是iOS,它可能是[应用程序传输安全问题。](http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security- enabled-in-ios-9) – Adam

+0

你是否缺少插件'cordova-plugin-whitelist'? – Akis

+0

这突然发生在我身上。任何想法为什么它以前工作,没有任何代码更改? –

回答

6
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; media-src *; img-src * filesystem: data:"> 

它固定的问题。刚刚添加在头部分。

+0

这也解决了我的问题!非常感谢。 – user1012181

0

我有确切的问题,但即使将元标记添加到头部,图像也不会由于CORS dom错误18而加载。我发现此链接https://github.com/niklasvh/html2canvas/pull/374,这导致我尝试将字符串添加到图像源,以防止图像缓存,它的工作!

var src = 'https://example.com/images/test.jpg'; 
img.src = src + this.createRequestString() + "?request=" + (new Date().getTime()) + (Math.random() * 50000);