【发布时间】:2020-05-04 12:47:09
【问题描述】:
vue js中动作完成后如何执行代码?这是我的登录操作
login: async ({commit},loginDTO)=>{
return commit('login',loginDTO);
}
我的登录突变是这样的:
login:(state, loginDTO)=>{
axios.post(loginEndpoint.login, loginDTO)
.then(resp => {
if(resp.data.statusCode == 1) {
state.user.userId = resp.data.userId;
state.user.response = resp.data.responseText;
localStorage.setItem("token", "token")
state.isLogin = true;
router.push({name: 'Systems'});
}
else{
alert(66);
state.user.response = resp.data.responseText;
}
})
.catch(err => {
})
}
我从这样的组件中调用它:
methods:{
...mapActions(['login']),
async login1(){
const loginDTO = {
Username : this.user.Username,
Password: this.user.Password
};
await this.$store.dispatch('login',loginDTO);
this.$toastr.s("Message", "");
}
}
现在我需要 toast 消息,但在操作完成后。 已更新。
【问题讨论】: