简体   繁体   English

无法在 Android 上使用 Cordova 和 Ionic 加载模块

[英]Cannot load module with Cordova and Ionic on Android

I am importing Ionic into my index.html with this:我将 Ionic 导入到我的 index.html 中:

<script type="module" src="ionic/ionic/ionic.esm.js"></script>
<script nomodule="" src="ionic/ionic/ionic.js"></script>

On Browser and iOS and even Android Emulator everything works fine.在浏览器和 iOS 甚至 Android 模拟器上一切正常。 Only on Android Devices I get Failed to load module script: The server responded with a non-JavaScript MIME type of "".仅在 Android 设备上,我Failed to load module script: The server responded with a non-JavaScript MIME type of "".

I found one or two questions on SO and issues on GitHub, but no simple solution to my problem..我在 SO 上找到了一两个问题,在 GitHub 上发现了问题,但没有简单的解决方案来解决我的问题..

How can I resolve the error?我该如何解决错误?

If you are loading from file protocol (default by cordova) you can't use modules.如果您从文件协议(cordova 默认)加载,则不能使用模块。

You can use cordova-plugin-ionic-webview, it loads from http or https and modules will work.您可以使用cordova-plugin-ionic-webview,它从http 或https 加载并且模块可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM