一:代码信息:
从/manage
<router-link to="/manage/alls" tag="li">
<i class="iconfont icon-liebiao"></i>所有文章
</router-link>
将要跳转到/manage/alls页面
在/manage/alls页面list.vue中,采用vuex获取数据:
mounted(){
//获取用户信息
this.getUserInfo();
console.log(this.userInfo.data[0].user_id);
this.renderse(this.userInfo.data[0].user_id);
},
computed: {
...mapState([
'userInfo',
]),
},
methods: {
...mapActions([
'getUserInfo',
]),
}
二:问题
需要在页面加载的时候使用userInfo,所以,当在/manage页面中点击跳转,页面可以成功显示并获取userInfo数据,但是当在地址栏回车时,在mounted中获取不到userInfo,但是页面上{{userInfo}}正常显示,这是什么原因呢,有哪位帮忙看看?非常感谢
可以尝试watch下路由,重新执行获取
userInfo
的方法