javascript - 如何在 UWP JavaScript 应用程序中显示状态栏?

标签 javascript uwp windows-10 windows-10-universal windows-10-mobile

用 JavaScript 编写应用程序时如何在移动设备上显示 Windows 10 系统状态栏? Windows.​UI.​View​Management.StatusBar 类在移动设备上不可用,Visual Studio 2017 是这样说的。

最佳答案

您需要添加对 UWP 移动扩展的引用,因为状态栏仅存在于移动设备上。

enter image description here

转到项目 > 添加引用。

选中“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/

相关文章:

javascript - 如何使用javascript从用户定义的excel文件中获取输入

javascript - VBA-Excel 将数据从站点复制到 Excel - 新单元格创建和 HTML 问题

javascript - 在 HTML 选择/选项下拉列表中携带一些额外信息

uwp - 获取通话记录仅返回最后 20 条日志

c++ - 如何在 C++/WinRT (`Promise.all` 等效项中等待多个可等待/IAsyncActions)?

python - 如何在Windows上使用cython_freeze构建单个可执行文件?

Android 6 Nexus 5 USB 连接问题

javascript回调函数调用自身直到为真

c# - 如何在 UWP 应用程序中编码/解码 url 字符串

python - 对于嵌入式 Python,前缀 PYTHONPATH 不在 sys.path 中