vue router.app.$store undefined

router.beforeEach((to, from, next) => {
  //这个是路由切换的时候可以获取到值,当前页面刷新获取不到 console.log(router.app.$store)
//undefined }

 

 

解决方法:router.js

// Vue.use(Router);  //这行注释,替换下面的代码

//这我也没看懂是什么,你们研究到告诉我
const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};

 

posted @ 2021-07-01 00:47  科技改变未来☆  阅读(63)  评论(0编辑  收藏  举报