vue
自定义指令
通过Vue.directive(name,{})
Vuex
- 三部分构成 state actions mutations
- state
此部分存放数据,可以通过mapStated获取到数据。


-
actions
可以使用异步,通过this.$store.dispathc()触发
-
mutatios
mutatios
必须是同步,通过this.emmit()触发
-
步骤:
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment (state) {
state.count++
}
},
actions: {
increment (context) {
context.commit('increment')
}
}
})
转载于:https://www.cnblogs.com/felearn/p/9437615.html