How to set the app of the vue-cli packaged by hbuilder to exit twice by pressing the return button on the phone?

how to set the app of the vue-cli packaged by hbuilder to exit twice by pressing the return button on the phone

I quit app by pressing the return button
how to get the first prompt to quit and then quit

Mar.06,2021

this problem has not been dealt with, but you can make some suggestions

js snooping comes with the return key. Currently, there is no solution. It can only be said that the return key is determined by other methods. To solve the problem of the return key, you need to use the native API.

var hiddenProperty = 'hidden' in document ? 'hidden' :    
    'webkitHidden' in document ? 'webkitHidden' :    
    'mozHidden' in document ? 'mozHidden' :    
    null;
var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange');
var onVisibilityChange = function(){
    if (!document[hiddenProperty]) {    
        console.log('');
    }else{
        console.log('')
    }
}
document.addEventListener(visibilityChangeEvent, onVisibilityChange);

this code does not listen for the return key, but determines whether to browse the current page to implement the requirements
using the new h5 feature, it is easy to listen to any App with the return key


plus.webview.currentWebview ()


have you solved this problem


index.html
clipboard.png

Menu