如果进入子页面需要一个主页面的列表的id。那么从子页面退回主页面后,可以点击浏览器返回上一页就进入了子页面。但是当前你的id是不知道的。
所以要禁止浏览器返回进入的子页面。
main.js
window.addEventListener('popstate', function() {
history.pushState(null, null, document.URL)
})
router.js
const router =
new
Router({
mode:
'hash'
,
routes,
scrollBehavior: () => {
history.pushState(
null
,
null
, document.URL)
}
})