远程图像未在 cordova 中加载
remote image not loading in cordova
我已将 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>
<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:">
它解决了这个问题。刚刚添加到头部。
我遇到了确切的问题,但即使将元标记添加到头部,图像也不会加载,因为 CORS dom 错误 18。我发现了这个 link 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);
我已将 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>
<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:">
它解决了这个问题。刚刚添加到头部。
我遇到了确切的问题,但即使将元标记添加到头部,图像也不会加载,因为 CORS dom 错误 18。我发现了这个 link 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);