問 題
做登錄頁面時,在vuex中的action異步提交后獲取的數據在mutations中存儲在state里面,但是總感覺不對,沒有返回數據,我前端頁面怎么獲取數據,用mapgetter獲取不到數據,是不是他不是實時更新的,而且輸出的mapgetter輸出的數據還在action的前面。下面是我前端部分代碼:
},
computed: {
...mapGetters({
userInfo: "users"
}),
},
methods: {
...mapActions({ //分發action
logins: "logins"
}),
submit: function () {
var $alert = $(".alert");
if (this.username === '') {
$alert.addClass("alert-danger");
$alert.html("用戶名不能為空");
this.showInfo = false;
} else if (this.password === '') {
$alert.addClass("alert-danger");
$alert.html("密碼不能為空");
this.showInfo = false;
} else {
var users