无法在Android上加载带有Cordova和Ionic的模块



我正在将Ionic导入我的索引.html如下:

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

在浏览器和iOS甚至Android模拟器上,一切正常。只有在安卓设备上我才能得到Failed to load module script: The server responded with a non-JavaScript MIME type of "".

我在SO上找到了一两个问题,在GitHub上发现了问题,但没有简单的解决方案来解决我的问题。

如何解决该错误?

如果你从文件协议加载(默认情况下是cordova(,你不能使用模块。

您可以使用cordova-plugin-ionic-webview,它从http或https加载,模块将工作。

最新更新