{"id":1016,"date":"2023-03-12T09:26:44","date_gmt":"2023-03-12T01:26:44","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1016"},"modified":"2023-04-29T13:15:34","modified_gmt":"2023-04-29T05:15:34","slug":"vuex-actions-pass-multiple-parameters","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/vuex-actions-pass-multiple-parameters\/","title":{"rendered":"Vuex\u7684actions\u4f20\u9012\u591a\u4e2a\u53c2\u6570"},"content":{"rendered":"<p>Vuex dispatch\u7684payload\u6700\u591a\u53ea\u80fd\u63a5\u6536\u4e00\u4e2a\u53c2\u6570<\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/vuex.vuejs.org\/api\/#dispatch\">https:\/\/vuex.vuejs.org\/api\/#dispatch<\/a><\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-javascript\">var params = {}\nparams.name = name\nparams.age = age\nself.$store.dispatch(&#039;userUpdate&#039;, {&#039;schoolCode&#039;: this.id, &#039;params&#039;: params})<\/code><\/pre>\n<pre><code class=\"language-javascript\">actions: {\n  \/\/ \u66f4\u65b0\u7528\u6237\u4fe1\u606f\n  userUpdate ({ commit }, object) {\n    api.user_update(object.id, object.params).then((response) =&gt; {\n      commit(types.COMMON_USER_UPDATE_CALLBACK, {&#039;httpCode&#039;: response.status, &#039;data&#039;: response.data})\n    }).catch((response) =&gt; {\n      commit(types.COMMON_USER_UPDATE_CALLBACK, {&#039;httpCode&#039;: response.status, &#039;data&#039;: response.data, &#039;localMsg&#039;: object.params.localMsg})\n    })\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vuex dispatch\u7684payload\u6700\u591a\u53ea\u80fd\u63a5\u6536\u4e00\u4e2a\u53c2\u6570 \u53c2\u8003\uff1ahttps:\/\/vuex.vuejs.o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[279],"class_list":["post-1016","post","type-post","status-publish","format-standard","hentry","category-vue","tag-vuex"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1016"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1016\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}