我正在使用 Cordova 构建包含 Ext.js Web 应用程序的 UWP Windows 10 应用程序。
我可以使用 Cordova 以及 cordova build windows
和 Sencha 的系统 sencha app build native
成功构建应用程序。这会在 cordova\platforms\windows\AppPackages
中输出一个文件夹,其中包含一个 .appx
文件,我可以在信任生成的 key 后安装该文件。
问题
安装完成后,如果“完成后运行”复选框保持选中状态,应用程序将加载,并且我会看到登录屏幕。 如果我通过按右上角的 X 关闭应用程序,然后从开始菜单重新打开应用程序,我看到的只是黑屏(实际颜色为 #1d1f20)。如果我卸载该应用程序并重新安装,它会再次运行,但只能运行一次。任何随后的关闭和重新打开都会导致黑屏。
如果我取消选中“完成后运行”复选框,然后手动打开应用程序,我也会看到黑屏。
当黑屏显示时,如果我按 F12 打开开发人员工具,然后按 Ctrl 和 R 重新加载,我会看到登录屏幕。没有控制台错误。
如果我在网络浏览器中从 cordova\platforms\windows\www
打开 index.html 文件,那么我会看到登录屏幕。
我尝试将配置添加到与启动屏幕相关的 config.xml,但这对这种情况没有帮助。
重申一下,该应用程序可以运行一次(如果立即启动),但随后所有后续启动都只会显示黑屏,除非我打开开发人员工具并手动重新加载
在 Visual Studio 中
如果我在 Visual Studio 中打开解决方案并在本地计算机上“运行”,它就会工作并且我会看到登录屏幕。
如果我转到“构建”>“部署解决方案”,它将在我的系统上安装该应用程序并运行它并且它可以工作。
这实际上会导致应用程序正常工作,即使在后续启动时也是如此!!
如果我转到“项目”>“商店”>“创建应用程序包”并创建应用程序包,我会遇到相同的黑屏问题(旁注,这会创建 .appxbundle 文件而不是 .appx 文件)。
我的系统详细信息:
- Windows 10 x64 版本 1709 操作系统内部版本 16299.192
- 节点:6.10.3
- npm:5.6.0
- Cordova :8.0.0
- Visual Studio:社区 2017 15.5.3
- JavaScript UWP 项目系统:2.0
- 适用于通用 Windows 应用的 Visual Studio 工具:15.0.27130.2020
- Ext.js 6.5.1
Cordova 配置文件
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foo.foomobile" version="1.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>FooMobile</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Foo Services
</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>
<plugin name="cordova-plugin-whitelist" spec="1" />
<preference name="windows-target-version" value="10.0" />
<preference name="KeepRunning" value="true" />
<engine name="android" spec="~6.2.3" />
<engine name="windows" spec="^5.0.0" />
</widget>
任何帮助将不胜感激。
编辑
我尝试使用新的空白 Ext.js 6.5.3 应用程序进行 Cordova 构建,并且首次启动工作和后续启动白屏也存在相同的问题。
编辑2
最佳答案
我与 Daniel Twigg 合作解决了这个问题。
问题出在 Sencha Ext JS 微加载器 (bootstrap.js) 中。由于某种原因,在 Windows 中将文件动态加载到微加载器完成的页面中存在问题 - 我有一个“bootstrap.js”文件的修改版本可以修复该问题 - 如果需要,请与我联系 - 或者我可以发布它这里
marc.gusmano@sencha.com
关于visual-studio - Cordova Windows 10 UWP 应用程序黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48475683/