解决方法就是,通过watch 监听路由的变化
created() {
this.itemId = this.$route.query.item_id
this.getUserInfo()
},
watch: {
'$route'(to, from) {
if (to.name === 'user-info'){// if 防止页面跳转到其它路由,多次触发的问题
this.itemId = this.$route.query.item_id
this.getUserInfo()
}
}
},
