LoginSignup
4
1

More than 5 years have passed since last update.

Vuexでnamespacedを使う時にexport default new Vuex.Storeにしたらエラーが出た

Last updated at Posted at 2018-04-07

問題

vuexでnamespaced: trueなmodulesをstoreにしようとしたらエラーが出た。

以下が動かない

src/comopnents/a-counter
computed: {
  ...mapGetters("a", [
    "count"
  ])
},

問題の箇所

src/store/index.html
export default new Vuex.Store({
  modules: {
    a,
    b
  }
src/index.js
import store from './store'

変更

src/store/index.html
export const store = new Vuex.Store({
  modules: {
    a,
    b
  }
src/index.js
import {store} from './store'

結果

変更するとnamespaced: trueなmodulesをstoreにして、

mapが使えるようになった。

src/comopnents/a-counter
computed: {
  ...mapGetters("a", [
    "count"
  ])
},
4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1