【问题标题】:Getting blank page in angular cordova app在角度科尔多瓦应用程序中获取空白页
【发布时间】: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

Blank Page Screenshot

这是 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>

我的错误在哪里?谢谢

【问题讨论】:

    标签: ios angular cordova


    【解决方案1】:

    你需要添加

    <script type=”text/javascript” src=”cordova.js”></script>
    

    在您的 index.html 文件中。 然后在 main.ts 中:

        let onDeviceReady = () => {
          platformBrowserDynamic().bootstrapModule(AppModule);
        };document.addEventListener('deviceready', onDeviceReady, false);
    

    喜欢这里: binding angular with cordova

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 1970-01-01
      • 1970-01-01
      • 2016-04-27
      • 2021-10-07
      • 2021-07-28
      • 2017-08-23
      相关资源
      最近更新 更多