在 android 离子应用程序中使用 ng-src 加载图像
Load image using ng-src in android ionic aplication
我也在使用 ionic、iOS 和 Android 开发应用程序。我必须在 url 使用 ng-src
加载外部图像:
http://test.url.eu:1337/fileuploads/receive/552f6d1786a3ea3772000004
它在 iOS 上工作正常,但在 android 上出现不安全错误,图像未加载。
我该如何解决这个问题?
编辑:
它适用于 android 4.4 和 5 但不适用于 < 4.4。我正在使用 crosswolk.. 谢谢
我有一个类似的问题,该应用程序在 PC 上运行良好,但在 android 上运行 404。
根据您的 Cordova 版本,如 Cordova Android 4.0.0 公告所示,自 Cordova 4.0.0 以来,您可能必须添加 cordoba-
Whitelist functionality is revamped
- You will need to add the new cordova-plugin-whitelist plugin to continue using a whitelist
- Setting a Content-Security-Policy (CSP) is now supported and is the recommended way to whitelist (see details in plugin readme)
- Network requests are blocked by default without the plugin, so install this plugin even to allow all requests, and even if you are using CSP.
- This new whitelist is enhanced to be more secure and configurable, but
the Legacy whitelist behaviour is still available via a separate plugin (not recommended).
- Note: while not strictly part of this release, the latest default app created by cordova-cli will include this plugin by default.
要安装:Cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git
。
在此之后,您需要添加强制内容安全策略:(一个简单的尝试是:<meta http-equiv="Content-Security-Policy" content="default-src *; img-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
但我建议阅读 http://content-security-policy.com 中的选项)。
不要忘记检查您的 config.xml 以定义访问来源(最简单的是 <access origin="*"/>
)。如果仍然不起作用,请查看 https://github.com/apache/cordova-plugin-whitelist#navigation-whitelist 以了解您是否需要导航或意图白名单。
祝你好运!
我也在使用 ionic、iOS 和 Android 开发应用程序。我必须在 url 使用 ng-src
加载外部图像:
http://test.url.eu:1337/fileuploads/receive/552f6d1786a3ea3772000004
它在 iOS 上工作正常,但在 android 上出现不安全错误,图像未加载。 我该如何解决这个问题?
编辑: 它适用于 android 4.4 和 5 但不适用于 < 4.4。我正在使用 crosswolk.. 谢谢
我有一个类似的问题,该应用程序在 PC 上运行良好,但在 android 上运行 404。 根据您的 Cordova 版本,如 Cordova Android 4.0.0 公告所示,自 Cordova 4.0.0 以来,您可能必须添加 cordoba-
Whitelist functionality is revamped
- You will need to add the new cordova-plugin-whitelist plugin to continue using a whitelist
- Setting a Content-Security-Policy (CSP) is now supported and is the recommended way to whitelist (see details in plugin readme)
- Network requests are blocked by default without the plugin, so install this plugin even to allow all requests, and even if you are using CSP.
- This new whitelist is enhanced to be more secure and configurable, but the Legacy whitelist behaviour is still available via a separate plugin (not recommended).
- Note: while not strictly part of this release, the latest default app created by cordova-cli will include this plugin by default.
要安装:Cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git
。
在此之后,您需要添加强制内容安全策略:(一个简单的尝试是:<meta http-equiv="Content-Security-Policy" content="default-src *; img-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
但我建议阅读 http://content-security-policy.com 中的选项)。
不要忘记检查您的 config.xml 以定义访问来源(最简单的是 <access origin="*"/>
)。如果仍然不起作用,请查看 https://github.com/apache/cordova-plugin-whitelist#navigation-whitelist 以了解您是否需要导航或意图白名单。
祝你好运!