简体   繁体   English

Android Cordova Statusbar插件-“ StatusBar.hide();”在哪里?

[英]Android Cordova Statusbar Plugin - Where does “StatusBar.hide();” go?

https://github.com/apache/cordova-plugin-statusbar says to use StatusBar.hide(); https://github.com/apache/cordova-plugin-statusbar表示要使用StatusBar.hide(); to hide the statusbar, but I don't see any documentation about where it goes other than "after the deviceready event", which doesn't explain which file it should go to? 隐藏状态栏,但是除了“ deviceready事件之后”之外,我没有看到任何其他有关它的去处的文档,该文档没有解释应该去哪个文件? index.js?? index.js ???

I've added the plugin and followed all the steps up to this -- adding a simple code snippet to a mystery file somewhere within the project (or program files??) :\\ 我已经添加了插件,并按照所有步骤进行了此操作-向项目内某个神秘文件(或程序文件?)中添加了一个简单的代码片段:\\

If anyone knows more about this I would really appreciate the help. 如果有人对此有所了解,我将非常感谢您的帮助。 Was looking around all day trying to get this working. 一整天都在四处寻找,以使其正常工作。

If you wanna hide status bar at startup, then you may have to invoke the hide function inside deviceready event listener. 如果要在启动时隐藏状态栏,则可能必须在deviceready事件监听器中调用hide函数。 So which file it should get into depends on where you have registered deviceready event listener. 因此,应将其放入哪个文件取决于您在哪里注册了设备就绪事件侦听器。

You can also invoke it anywhere in your app where you wanna hide your statusbar provide the plugin is completely loaded. 您也可以在应用程序中要隐藏状态栏的任何地方调用它,前提是该插件已完全加载。 But generally the most used scenario is to hide the statusbar on app startup. 但通常最常用的方案是在应用启动时隐藏状态栏。 More info on achieving this available in the offical docs and SO post 有关实现此目标的更多信息,请参见官方文档SO帖子

If you want to hide status bar ASAP use deviceready event on index.html: 如果要尽快隐藏状态栏,请在index.html上使用deviceready事件:

document.addEventListener("deviceready", function () { StatusBar.hide(); }, false);

Also you can use a separate js file for it. 您也可以使用单独的js文件。

Unfortunately, none of these solutions worked for me (although they should be correct and are mentioned all over the internet). 不幸的是,这些解决方案都不适合我(尽管它们应该是正确的,并且在整个互联网上都被提及)。 This is what did it for me, placing this at the bottom of my www/index.html file: 这就是为我做的,将其放在我的www / index.html文件的底部:

<script> 
$(window).bind("load", function() {
StatusBar.hide();
});
</script>

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

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