vue router.app.$store undefined

时间:2021-07-01 09:36:30   收藏:0   阅读:42
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);
};

 

原文:https://www.cnblogs.com/codeDevotee/p/14957076.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!