首页 > 解决方案 > Cordova ios angularjs没有找到模板

问题描述

当我尝试使用我在 xcode 中构建的 cordova ios 应用程序时遇到问题。它开始了,然后我收到一个错误,即 angularjs 无法加载模板。相同的应用程序在浏览器和安卓上运行良好。

我构建它的步骤

科尔多瓦在终端中构建 ios。

然后我打开 .xcworkspace 文件以在 xcode 中打开它。然后我将它构建到连接的 iphone。我得到一个启动画面,我看到我的 init promisechain 运行但随后它停止了。

templateUrl: 'js/modules/header/html/header.html',

文件结构是 www -> js -> 模块 -> header -> html -> header.html

我得到的错误是:

020-05-13 15:59:05.496068+0200 [3439:2658415] 错误:[$templateRequest:tpload ] http://errors.angularjs.org/1.7.8/$templateRequest/tpload?p0=.%2Fjs% 2Fmodules%2Fheader%2Fhtml%2Fheader.html&p1=-1&p2= file:///var/containers/Bundle/Application//.app/www/js/node_modules/angular/angular.min.js:7

任何人都知道如何解决它?

标签: ioscordovaphonegap

解决方案


So the problem was CORS.

After installing the plugin https://github.com/oracle/cordova-plugin-wkwebview-file-xhr it works as intended. I think they will solve it in cordova-plugin-wkwebview but for now the xhr plugin is necessary.


推荐阅读