在vue组件中的computed中获取了vuex中的属性,然后在created生命钩子中使用state中的属性发送了请求发现mounted发送请求时参数没有获取到,页面更新之后才正确:
computed: {
...(mapState({
user_name: state => state.user_name,
user_id: state => state.user_id,
user_source: state => state.user_source,
}))
}
created() {
request(extend(true, {}, apis.getUserConsultInfo, {
params: {
consult_id: this.consult_id,
user_id: this.user_id,
user_source: this.user_source
}
})).then((res) => {
console.log(res);
}, (errmsg) => {
this.$message.error(errmsg);
});
}
这种情况怎么破?求大神解决~~
慕丝7291255
相关分类