如何在 ...mapState (Vuex) 之间设置一个值
How set a value between ...mapState (Vuex)
在Vuex和View中,如何在...mapActions(["getConfig"])
之间设置一个值或执行一个函数?
例如:
methods: {
this.theValue=true
...mapActions(["getConfig"])
this.theValue=false
}
将回复写成评论太短了。
包装动作
您需要调用一个操作,还需要设置一些特定于您的组件的值。您需要包装您的操作调用,例如
{
// ...
methods:{
...mapActions(["getConfig"]),
doGetConfig: async function(){
this.theValue = true;
await this.getConfig();
this.theValue = false;
}
}
}
您必须假设所有操作都是异步的,因此 async / await
。
getConfig
与您的问题无关,但 getConfig
听起来是 getter 的名字。我假设上面的答案是 loadConfig
在Vuex和View中,如何在...mapActions(["getConfig"])
之间设置一个值或执行一个函数?
例如:
methods: {
this.theValue=true
...mapActions(["getConfig"])
this.theValue=false
}
将回复写成评论太短了。
包装动作
您需要调用一个操作,还需要设置一些特定于您的组件的值。您需要包装您的操作调用,例如
{
// ...
methods:{
...mapActions(["getConfig"]),
doGetConfig: async function(){
this.theValue = true;
await this.getConfig();
this.theValue = false;
}
}
}
您必须假设所有操作都是异步的,因此 async / await
。
getConfig
与您的问题无关,但 getConfig
听起来是 getter 的名字。我假设上面的答案是 loadConfig