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')