W
e
l
c
o
m
e
: )

vue封装js中使用router

vue封装的公共方法js中使用router,页面可能报错

可在js中添加

import Router from 'vue-router'
import router from '../router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}
 
引用router.push('/path')
posted @ 2020-04-13 17:51  口木秋子  阅读(2591)  评论(0编辑  收藏  举报