gpt4 book ai didi

javascript - vuex 订阅个体变异

转载 作者:可可西里 更新时间:2023-11-01 01:44:43 25 4
gpt4 key购买 nike

是否可以订阅单个突变?

代替:

this.$store.subscribe((mutation, state) => {
if(mutation === 'someMutation'){
doSomething()
}
})

我想要这样的东西:

this.$store.subscribe('someMutation', state => {
doSomething()
})

最佳答案

来自 vuex 文档:

The handler is called after every mutation and receives the mutationdescriptor and post-mutation state as arguments.

它会对所有的变化使用react,所以你只能用你自己的条件来实现。

关于javascript - vuex 订阅个体变异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45845789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com