vue中beforeRouteEnter使用this的方法

data() {
return {
active: 1
}
},

beforeRouteEnter(to, from, next) {
next((vm) => {
if (from.query.active) {
vm.$nextTick(() => {
vm.active = from.query.active
})
vm.onClick()
}
})
},

methods: {
onClick() {
console.log('ssss')
}
}

posted on 2023-01-13 17:53  苏舒  阅读(354)  评论(0编辑  收藏  举报