[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
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM