【发布时间】:2019-10-25 10:59:00
【问题描述】:
我正在通过如下组件调用商店操作:
sublitPost(){
this.$store.dispatch({type:"submitPost", userPost:this.newPost});
}
商店操作如下所示:
actions: {
submitPost({commit, state}, userPost: any) {
/...rest code here
尽管如此,我想简化这一点并将操作称为:
sublitPost(){
this.$store.dispatch("submitPost", this.newPost);
}
我必须对动作签名进行哪些调整?我尝试过的操作如下:
actions: {
submitPost(userPost: any) {
console.log({userPost})
/...rest code here
但在这种情况下,接收到的对象看起来不正确。我在控制台日志中得到的是:
欢迎任何帮助
【问题讨论】: