【发布时间】:2021-07-06 21:15:27
【问题描述】:
我正在尝试在 Angular + Cordova 中运行 HelloWorld 应用程序,但是当我使用 ios 模拟器(iPhone 12 Pro Max - iOS 14.4)运行它时,它无法正常运行。我得到一个空白页(下面的屏幕截图)。
我已经将 index.html 中的 href="/" 更改为 href="./" 但它不起作用。我使用“cordova platform add ios”命令行添加了 ios 平台,并安装了所有要求:XCode、ios-deploy 和 CocoaPods 工具。
我使用 Angular CLI 创建了 Angular 项目并且没有修改任何内容。之后,我在里面创建了 Cordova 项目并将 dist 文件夹链接到 www 文件夹。
版本: Cordova 版本 10.0.0 - Angular 版本 11.2.9 - Angular CLI 版本 11.2.8 - Node 版本 15.14 .0
这是 config.xml 文件:
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
这是 www 文件夹中的 index.html 文件:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HelloWorldAngularCordova</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.3ff695c00d717f2d2a11.css"></head>
<body>
<app-root></app-root>
<script src="runtime.7b63b9fd40098a2e8207.js" defer></script><script src="polyfills.00096ed7d93ed26ee6df.js" defer></script><script src="main.80cad638da592e13f2e3.js" defer></script></body>
</html>
我的错误在哪里?谢谢
【问题讨论】: