场景:公司vue开发的app,打包测试,返回键直退出app解决办法:
<script>
document
.addEventListener('plusready', function() {
var webview
= plus
.webview
.currentWebview();
plus
.key
.addEventListener('backbutton', function() {
webview
.canBack(function(e
) {
if(e
.canBack
) {
webview
.back();
} else {
webview
.close();
}
})
});
});
document
.addEventListener('plusready', function(a
) {
var first
= null
;
plus
.key
.addEventListener('backbutton', function() {
if (!first
) {
first
= new Date().getTime();
console
.log('再按一次退出应用');
setTimeout(function() {
first
= null
;
}, 1000);
} else {
if (new Date().getTime() - first
< 1000) {
plus
.runtime
.quit();
}
}
}, false);
});
</script
>
其他碰到的问题:
设置沉侵式状态栏
"statusbar":{
"immersed": true/*沉浸式状态栏*/
},