Vue中如果想要监听到网页是否点击了浏览器的返回,可以在beforeCreate
中创建监听事件
例子如下
beforeCreate () {
let that = this
window.addEventListener('popstate', this.func)
}
method: {
func() {
console.log('触发了浏览器返回)
}
}
beforeCreate
中创建监听事件例子如下
beforeCreate () {
let that = this
window.addEventListener('popstate', this.func)
}
method: {
func() {
console.log('触发了浏览器返回)
}
}