[vuex] unknown action type: user/resetToken 报错 Vuex中使用store.dispatch('user/resetToken')如果无法获取到 actions

export default {
    namespaced: true,//在这里控制  
state,
mutations,
actions }
import Vue from 'vue'
import { Req_getToken } from '@/api/user'
const user = {
    state: {
        device: 'android',
        userinfo: '',
        childalbums: "" //子相册列表
    },

    mutations: {
        SET_CHILDALBUMS: (state, childalbums) => {
            state.childalbums = childalbums
        },
    },

    actions: {
        // remove token
        resetToken() {
            return new Promise(resolve => {
                let dataVal = { userName: "nies", password: "111111" };
                Req_getToken(dataVal).then((res) => {
                    resolve();
                    console.log(res)
                }).catch(err => {
                    console.log(err);
                    reject(err)
                });
            });
        },

    }
}

export default user















import { Req_getToken } from '@/api/user'

//import Layout from '@/layout'

const state = {

}

const mutations = {

}

const actions = {

    // remove token
    resetToken({ commit }) {
        console.log("获取到了")
        return new Promise(resolve => {

            // resolve();
            let dataVal = { userName: "nies", password: "111111" };
            Req_getToken(dataVal).then((res) => {
                resolve(res);
                console.log(res)
            }).catch(err => {
                console.log(err);
                reject(err)
            });
        });
    },
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
原文地址:https://www.cnblogs.com/dianzan/p/13225818.html