1.0.9 • Published 4 years ago

vuex-convert v1.0.9

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

Vuex-Convert

Version 1.0.2

Description(简述)

  • Simplify vuex configuration(简化Vuex配置,让你的团队更容易上手)

Install(安装)

$ npm i vuex-convert

Basic usage(基本用法)

  • Create store.js
// /conf/store.js
import Vue from 'vue'
import Vuex from 'vuex'
import VuexConvert from 'vuex-convert'

const STORE = new VuexConvert({
  // State Data(状态变量)
  public:{
    base: 'Hello Vuex'
    // ...other state(其他状态)
  },
  // Modules Data(存放Modules变量)
  modules:{
    user:{
      name: 'Pi'
    }
    // ...other state(其他状态)
  }
})

Vue.use(Vuex)
export default new Vuex.Store(STORE)
  • main.js
import store from './conf/store.js'
  
new Vue({
    store,  // <---- add store
    // Other content
})

Use the demo (使用案例)

// app.vue
export default {
  name: 'App',
  mounted(){
   // get Data
   console.log(this.$store.state.base) // --> "Hello Vuex"
   console.log(this.$store.getters.getBase) // --> "Hello Vuex"
   console.log(this.$store.getters["user/getName"]) // --> "Pi"
    
    // set Data 
    this.$store.dispatch('setBase', 'Update Hello')
    console.log(this.$store.state.base) // --> "Update Hello"
  }
}

Link

1.0.9

4 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago