我加在点击事件里面了,点击一下触发增加历史栈(直接cv)
const handelClick = () => {
window.addEventListener('popstate', e => {
// 阻⽌默认的返回事件
e.preventDefault()
//" 需要跳转的新⻚⾯或者做其他操作都可以
location.href = 'https://blog.csdn.net/qq_62809806/article/details/127509387'
})
// 增加历史记录栈
const originHref = window.location.href
const originState = window.history.state
console.log(originHref, originState)
history.pushState(
Object.assign({}, originState, {
visited: true
}),
'',
originHref
)
}