What exactly is namespacing of modules in vuex

前端 未结 4 931
再見小時候
再見小時候 2021-02-07 03:07

I have recently started with vuex.

The official docs explains well what modules are but i am not sure if i understood the namespaces in mo

4条回答
  •  独厮守ぢ
    2021-02-07 03:30

    I'm not an expert in vue.js but as I can see in the docs namespacing can be used to modify the path access to a module's getters/actions/mutations.

    By default namespaced: false all of the getters, actions, mutations are available gloabally by the different modules so if you want to use the same getter/action/mutation in different modules you must flag them as namespaced: true, otherwise an error will be thrown.

    Another use of this is to organize your getters/actions/mutations in different paths (the one that a module is registered at); this is very useful in large projects because you can know right away where the getter/action/mutation is defined so its easier to locate them.

    HIH

提交回复
热议问题