Then()函数未在vue存储函数中执行

问题描述 投票:0回答:1

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);
                });
        }
    },

如果您知道原因,请告诉我

vue.js nuxt
1个回答
0
投票

不是吗:

this.$axios.get(`http://localhost:3085/posts?offset=${state.mainPosts.length}&limit=10`)

&之前注意limit=10

© www.soinside.com 2019 - 2024. All rights reserved.