简体   繁体   English

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

[英]How to show status bar in UWP JavaScript app?

How to show the Windows 10 system status bar on mobile when writing the app in JavaScript? 使用JavaScript编写应用程序时如何在移动设备上显示Windows 10系统状态栏? The Windows.​UI.​View​Management.StatusBar class is not available on Mobile, or so says Visual Studio 2017. Windows.​UI.​View​Management.StatusBar类在Mobile上不可用,或者说Visual Studio 2017。

You need to add the references to the UWP Mobile Extension, because the status bar only exists on Mobile. 您需要将引用添加到UWP Mobile Extension,因为状态栏仅存在于Mobile上。

在此处输入图片说明

Go to Project > Add References. 转到项目>添加引用。

Check "Windows Mobile Extension for the UWP" and press "OK". 检查“用于UWP的Windows Mobile扩展”,然后按“确定”。

WARNING : You need to check if the API is present because the app can crash if it is not. 警告 :您需要检查 API是否存在,因为如果不存在该应用程序可能会崩溃。 Like this: 像这样:

if (Windows.Foundation.Metadata.ApiInformation.isTypePresent("Windows.UI.ViewManagement.StatusBar")) {

    let statusbar = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
    statusbar.showAsync();

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM