Use the API provided by H5 to work with popStates events

Take VUE as an example:

mounted() {
    if(window.history && window.history.pushState) {// Add the current address to the page stack, Popstate window.history.pushState(null, NULL, document.url); window.addEventListener('popstate', this.goBack, false)}},destroyed() {/ / page destruction to remove surveillance popstate window. RemoveEvenListener ('popstate', this.goBack, false)
},

methods: {
    goBack() {// jump to home page this.$router.replace({name: home})
    }
}
Copy the code

The replacEstate API is the same as the pushState API, except that the replacEstate API modiates the previous record in the page stack, while the PushState API adds a new record