简体   繁体   中英

Vuex default store in Nuxt.js

my app is in vue.js, now I want to rewrite it in nuxt.js, I have also vuex store in my app, for nuxt.js, vuex store syntax is different, is there any way to use my default store in nuxt.js without changing it? thanks and sorry for my English:))

It's not different. You don't change it significantly.

All you have to do is put it into separate js file and a little rewrite:

export const state = () => {

  return {
    cart: [],
    other_variables:{},
  }
}

export const mutations = {
// put all mutations here
}

name it index.js and put it into "store" folder. That's it. Just use it as before. Easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM