1.main.js中,增加popstate监听
window.addEventListener('popstate', function() {
history.pushState(null, null, document.URL)
})
2.router的index.js中:
const router = new Router({
mode: 'hash',
routes,
scrollBehavior: () => {
history.pushState(null, null, document.URL)
}
})