export default {
install (Vue) {
Vue.mixin({
mounted () {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL)
window.addEventListener('popstate', this.funBack, false)
}
},
destroyed () {
let currentRt = this.$router.currentRoute.name
console.log('destroyed currentRouter = ', currentRt)
window.removeEventListener('popstate', this.funBack, false)
}
})
}
}
import Minxin from './components/js/Minxin'
......
Vue.use(Minxin)
我怀疑你有多个组件,所以才会执行多次,你试一下吧console.log打印的currentRt换成this,看看this是不是相同的对象
https://blog.csdn.net/will4906/article/details/82586587?utm_source=blogxgwz5