<input value="增加" @click='increase'>
<div>当前数字:{{ count }}<div>
import { mapGetters,mapActions } from 'vuex'
computed:mapGetters([
'cout'
])
methods:mapActions([
'increase'
])
Vue.use(vuex)
var state = {
count: 10
}
const mutation = {
increase(state){
state.count++ // 处理数据状态变化
}
}
const actions = {
icrement: ({
commit // 异步请求,判断,流程控制, 还有一个数据state对象
})=> {
commit('increment')
}
}
export default Vuex.Store({ //导出Store对象
state,
mutations,
actions
});
状态管理模式vuex
最新推荐文章于 2020-12-22 14:39:06 发布