@2890594972
2017-10-26T00:47:28.000000Z
字数 614
阅读 930
vue
第一:调用mutations:
this.$store.commit('changeKeyword',this.iptValue);
第二:mutations修改state
mutations:{changeKeyword(state,newkeyword){state.keyword = newkeyword;}}
第三:state如何定义
state: {title:'1506',keyword:''}
第四:js组件化
export default new Vuex.Store({})
最后:综上所述
import Vue from 'vue'import Vuex from 'vuex'Vue.use(Vuex)//暴露对象接口export default new Vuex.Store({state: {title: '1506',keyword: ''},mutations: {autoIncrement(state, param) {+state.title++},changeKeyword(state, newkeyword) {state.keyword = newkeyword;}},actions: {//triggerMe如何触发triggerMe(actions, v) {}}})
实力化组件
new Vue({el: '#app',router,store,template: '<App/>',components: { App }})
