Ionic默认选项卡模板中的外部图像不会加载到模拟器和设备上

时间:2022-06-12 13:02:00

The tab app template in Ionic contains a few external images, and they won't load when I open the app in my Android emulator or my Nexus 5. Both the device and the emulatir do have internet connection and I can load these images manually in the browser.

Ionic中的选项卡应用程序模板包含一些外部图像,当我在Android模拟器或Nexus 5中打开应用程序时,它们无法加载。设备和模拟器都有互联网连接,我可以手动加载这些图像浏览器。

It works OK in the browser (ionic serve).

它在浏览器中工作正常(离子服务)。

That is:

ionic start myApp tabs
cd myApp
ionic serve # OK
ionic platform add android
ionic build android
ionic emulate android # Images are not loaded
ionic run android # Images are not loaded

ionic serve:

http://content.screencast.com/users/yuri_l/folders/Jing/media/e95e5f91-c732-414a-9ba5-adaf8a726dd5/00000064.png

Android emulator (Nexus 5):

Android模拟器(Nexus 5):

http://content.screencast.com/users/yuri_l/folders/Jing/media/a515d587-0eea-4978-809d-b800899aa9f9/00000065.png

ionic 1.3.22 cordova 5.0.0

离子1.3.22 cordova 5.0.0

What I am missing?

我错过了什么?

2 个解决方案

#1


Here is the solution:

这是解决方案:

ionic plugin add cordova-plugin-whitelist

External resources won't load without it.

没有它,外部资源将无法加载。

#2


As joeri said:

正如joeri所说:

ionic plugin add cordova-plugin-whitelist

离子插件添加cordova-plugin-whitelist

will fix the issue, Here is the api link to explain how it works. plugin API

将解决问题,这是api链接,以解释它是如何工作的。插件API

in my cordova config.xml file I have

在我的cordova config.xml文件中

<access origin="*"/>

doing this Doesn't block any requests

这样做不会阻止任何请求

The API explaination has a few more options if you want to restrict it more, here

如果您想在此更多地限制它,API解释还有一些选项

#1


Here is the solution:

这是解决方案:

ionic plugin add cordova-plugin-whitelist

External resources won't load without it.

没有它,外部资源将无法加载。

#2


As joeri said:

正如joeri所说:

ionic plugin add cordova-plugin-whitelist

离子插件添加cordova-plugin-whitelist

will fix the issue, Here is the api link to explain how it works. plugin API

将解决问题,这是api链接,以解释它是如何工作的。插件API

in my cordova config.xml file I have

在我的cordova config.xml文件中

<access origin="*"/>

doing this Doesn't block any requests

这样做不会阻止任何请求

The API explaination has a few more options if you want to restrict it more, here

如果您想在此更多地限制它,API解释还有一些选项