What are the problems encountered in the mixed development of mobile phone app with vue single-page applications?

if you want to listen to the physical return key of a mobile phone in each sub-page to specify a route jump, instead of performing a step-by-step jump through history, you can install the listening method on the lifecycle mounted of each sub-page

mounted () {
    this.addPopState();
},
methods: {
    addPopState() {
        window.addEventListener("popstate",function(){})//popstate
    }
}

but the problem is that the same event is bound in multiple pages, resulting in being overwritten. Is there any good solution?

kneel down and thank you!

May.26,2021

Why not listen for events in your parent components, and then listen for routing changes in (to, from)?


addEventListener can be bound multiple times without overwriting the previous event. Is it affected elsewhere?
what I do to listen for events like this is to listen in the root component and then use $on $emit distribute events
root component to listen and distribute

window.addEventListener('popstate', () => {
  this.$root.$emit('popstate')
})

listen anywhere at all levels of subcomponents

this.$root.$on('popstate', () => {

})

the bug that has been difficult for several days is solved. The reason is that the cordova native button is used in the mixed development, which causes the original return key to be triggered when the page triggers the physical return key. The solution is to cancel the native return button function, and the front-end page binds the event of the physical return key, so the result of triggering the return key returns to normal.

document.addEventListener("backbutton", onBackKeyDown, false);

function onBackKeyDown() {
    // Handle the back button
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ac1d-2c247.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ac1d-2c247.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?