vue router.app.$store undefined

2021/7/1 6:22:27

本文主要是介绍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);
};

 



这篇关于vue router.app.$store undefined的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程