各位大大,前周看了阮大大关于函数式编程介绍Ramda.js学习了下。
但应用在Vuex的框架下,关于mutaions state赋值不知正确的姿势如何?
mutations example 假设通过函数式编程计算后要变更count值:
const store = new Vuex.Store({
state: {
count: 1
},
mutations: {
increment (state) { // 方式1: 这样无法变更值
state = R.assoc('count', 3, state)
// 方式2: 把count包进去另外个package object (这样可以变更值)
state.package = R.assoc('count', 3, state.package)
}}
})
请问如果要使用Ramda.js正确的赋值方式姿势如何??
慕妹3242003
HUWWW
随时随地看视频慕课网APP
相关分类