在Windows上运行cordova应用程序后出现白屏/黑屏,但在浏览器中一切正常

时间:2019-01-12 20:05:51

标签: android windows cordova

我创建示例cordova应用程序模板,在 www 目录中实现我的代码,然后在浏览器Chrome,Edge,Firefox中运行,一切正常。

cordova run browser

enter image description here

但是如果我执行

cordova run windows

项目构建成功,但是我只看到白屏/黑屏

enter image description here enter image description here

Android构建中的相同问题

有我的配置

<?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" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <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>
    <engine name="browser" spec="^5.0.4" />
    <engine name="windows" spec="^6.0.1" />
    <engine name="android" spec="^7.1.4" />
</widget>

问题出在哪里?没有错误,没有调试信息

2 个答案:

答案 0 :(得分:1)

如果控制台中没有错误,则可能不是像这样删除config.xml文件中的启动画面

<preference name="SplashScreenDelay" value="10000" />

或者在deviceReady事件之后,您可以使用cordova-splash plugin自己进行操作。

答案 1 :(得分:0)

尝试以下方法之一:

  1. 从顶部(既不在头部也不在体内)移除cordova.js标签,并将以下代码恰好放在</body>标签之前(就在关闭body标签之前):
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
    app.initialize();
</script>
  1. 从您的config.xml中删除所有三个engine规范。