IONIC:无法加载资源:不受支持URL
IONIC: Failed to load resource: unsupported URL
我正在使用 ionic 和 iOS9 开发一个类似 Instagram 的应用程序,我遇到了一个奇怪的错误,我在网上寻找解决方案,但没有找到有用的东西。奇怪的是,屏幕底部的过滤器使用相同的图像,但它在那里工作。
GapDebug 抛出此错误:
未能unsafe:file:///var/mobile/Containers/Data/Application/AC45E204-30FB-4F61-92DF-97B840149D7D/tmp/cdv_photo_002.jpg 加载资源:不支持URL
Solution:
add this to your .config in app.js
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|file|mailto|chrome-extension):/);
您可能没有使用版本号,这迫使您使用 white-lists。将您的 Cordova 编译器版本设置为 4.0.0 之前的版本,例如 3.7.1 _OR_ 设置、white-list
、white-list plugin
,以及 CSP
(见文档底部)
如果您在 img
src
上遇到此错误,那么这可能是您正在寻找的白名单配置:$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|content|file|assets-library):|data:image\//);
尝试将以下内容添加到 index.html
的 <head>
中:
<meta http-equiv="Content-Security-Policy" content="
default-src 'self' data: gap: *;
script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
style-src 'self' 'unsafe-inline' 'unsafe-eval' *;
media-src 'self' 'unsafe-inline' 'unsafe-eval' *;
img-src 'self' 'unsafe-inline' 'unsafe-eval' * data:;">
我正在使用 ionic 和 iOS9 开发一个类似 Instagram 的应用程序,我遇到了一个奇怪的错误,我在网上寻找解决方案,但没有找到有用的东西。奇怪的是,屏幕底部的过滤器使用相同的图像,但它在那里工作。
GapDebug 抛出此错误:
未能unsafe:file:///var/mobile/Containers/Data/Application/AC45E204-30FB-4F61-92DF-97B840149D7D/tmp/cdv_photo_002.jpg 加载资源:不支持URL
Solution: add this to your .config in app.js
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|file|mailto|chrome-extension):/);
您可能没有使用版本号,这迫使您使用 white-lists。将您的 Cordova 编译器版本设置为 4.0.0 之前的版本,例如 3.7.1 _OR_ 设置、white-list
、white-list plugin
,以及 CSP
(见文档底部)
如果您在 img
src
上遇到此错误,那么这可能是您正在寻找的白名单配置:$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|content|file|assets-library):|data:image\//);
尝试将以下内容添加到 index.html
的 <head>
中:
<meta http-equiv="Content-Security-Policy" content="
default-src 'self' data: gap: *;
script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
style-src 'self' 'unsafe-inline' 'unsafe-eval' *;
media-src 'self' 'unsafe-inline' 'unsafe-eval' *;
img-src 'self' 'unsafe-inline' 'unsafe-eval' * data:;">