Skip to content

how to use modules in vuex4.0 #1833

Open
@devin-huang

Description

@devin-huang

Version

4.0.0-beta.4

import { createStore } from 'vuex'
import * as types from './mutation-type'

export default createStore({
  modules: {
    common: {
      namespaced: true,
      state: {
        device: '',
      },
      mutation: {
        [types.SET_DEVICE_LIST](state: any, device: string) {
          state.device = device
        },
      },
      actions: {
        findDeviceList: findDeviceList({commit}, params) {
            commit(types.SET_DEVICE_LIST, 'success')
        }
      },
   }
  },
})

output errpr:

[vuex] unknown local mutation type: SET_DEVICE_LIST, global type: common/SET_DEVICE_LIST

Steps to reproduce

when use vuex3.0 is ok, but vue4.0 use moduels is error, not to find commit path

What is expected?

how to vuex4.0 use modules the commit of mutation

Metadata

Metadata

Assignees

No one assigned

    Labels

    4.xneed reproReproduction code is required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions