需求:想要拦截this.$router里面的方法进行拦截、但是找不到正确的this
const main = {
install(Vue) {
// 重写replace 方法
Vue.prototype.$_router = {
push(){
// this.$router.push(ars)
console.log(this)
}
}
},
}
Vue.use(main)
需求:想要拦截this.$router里面的方法进行拦截、但是找不到正确的this
const main = {
install(Vue) {
// 重写replace 方法
Vue.prototype.$_router = {
push(){
// this.$router.push(ars)
console.log(this)
}
}
},
}
Vue.use(main)
13 回答12.9k 阅读
7 回答2.1k 阅读
9 回答1.7k 阅读✓ 已解决
6 回答1.5k 阅读
3 回答2.6k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
应该是修改route的原型
route.prototype.push=()=>{}