【发布时间】:2018-09-01 11:30:21
【问题描述】:
我对这家vuex 商店有一些疑问
export default {
state: {
resultSet: [
{
name: "result 1"
deep: {
inside: {
isLoading: false
}
}
},
{
name: "result 2"
deep: {
inside: {
isLoading: false
}
}
},
]
},
actions: {
/*
r is an item of the resultSet in the store (so r is a part of the store)
*/
sendQuery(context, r) {
//Here I mutate r directly (it means that I mutated the store directly without commit a mutation)
r.deep.inside.isLoading = true;
//Everything work, the UI is updated along with the state changes, but I'm not sure that
//I'm doing the right thing (mutate the store indirectly without committing a mutation)
}
}
}
问题:
将存储的一部分作为操作的有效负载分派是否正确? => 该动作可能会直接改变 r 的状态。
在上述动作中修改
r.deep.inside.isLoading=true是否正确?
【问题讨论】: