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

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-05-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2021-08-26
  • 2021-10-30
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
相关资源
相似解决方案