1.问题描述
在cordova 5.0 以上的版本打包app,会有外部访问白名单设置,从而无法再webapp内部访问外部链接。
2.问题原因
在默认的情况下,比如在ionic应用中,是不能访问外部链接的,为什么这样设置呢,当然是因为安全原因。我试验了一次,使用cordova-plugin-whitelist 设置可以打开所有的外部链接,结果有惊喜哟,中间出现了 xxx.av.com,哈哈!查阅了资料这是因为网络劫持造成的,所以出于安全问题的考虑,一个webApp应用必须限制访问白名单。
3.解决方案
使用插件 cordova-plugin-whitelist 设置白名单。插件包链接:https://www.npmjs.com/package/cordova-plugin-whitelist。