用 JavaScript 编写应用程序时如何在移动设备上显示 Windows 10 系统状态栏? Windows.UI.ViewManagement.StatusBar
类在移动设备上不可用,Visual Studio 2017 是这样说的。
最佳答案
您需要添加对 UWP 移动扩展的引用,因为状态栏仅存在于移动设备上。
转到项目 > 添加引用。
选中“UWP 的 Windows Mobile 扩展”,然后按“确定”。
警告:您需要检查 API 是否存在,因为如果不存在,应用程序可能会崩溃。像这样:
if (Windows.Foundation.Metadata.ApiInformation.isTypePresent("Windows.UI.ViewManagement.StatusBar")) {
let statusbar = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
statusbar.showAsync();
}
关于javascript - 如何在 UWP JavaScript 应用程序中显示状态栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44098367/