Then()函数未在vue存储功能中执行。
打印以下控制台消息
console.log("loadPosts check 11");
console.log("loadPosts check 22");
但是不打印
console.log("res : ", res);
也许then()不会受到谴责但我不知道原因
loadPosts({ commit, state }, payload) {
console.log("loadPosts check 1111");
if (state.hasMorePost) {
console.log("loadPosts check 2222");
this.$axios.get(`http://localhost:3085/posts?offset=${state.mainPosts.length}&limit=10`)
.then((res) => {
console.log("res : ", res);
commit('loadPosts', res.data);
}).catch((err) => {
console.log("err : ", err);
});
}
},
如果您知道原因,请告诉我
不是吗:
this.$axios.get(`http://localhost:3085/posts?offset=${state.mainPosts.length}&limit=10`)
在&
之前注意limit=10
。