{"id":53493,"date":"2024-12-03T17:37:20","date_gmt":"2024-12-03T09:37:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53493\/"},"modified":"2024-12-03T17:37:20","modified_gmt":"2024-12-03T09:37:20","slug":"vuex-store-%e4%b8%ad-data-%e4%b8%ba%e4%bb%80%e4%b9%88%e8%bf%94%e5%9b%9e-null%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53493\/","title":{"rendered":"Vuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Vuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f<\/h1>\n<p>\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aVuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f\u300b<\/span>\u4e3b\u8981\u8bb2\u89e3\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6211\u4f1a\u5728\u7c73\u4e91\u4e2d\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u5e76\u79ef\u6781\u7559\u8a00\u5efa\u8bae\u3002\u4e0b\u9762\u5c31\u5148\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u672c\u7bc7\u6b63\u6587\u5185\u5bb9\u5427\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733017361674bbf112c3f5.jpg\" class=\"aligncenter\" title=\"Vuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f\u63d2\u56fe\" alt=\"Vuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>vuex store \u7684 data \u8fd4\u56de\u7ed3\u679c\u4e3a null \u7684\u539f\u56e0<\/strong><\/p>\n<p>\u5728 vuex store \u4e2d\u5b9a\u4e49\u7684 action \u91cc\u6709\u4e00\u4e2a store \u65b9\u6cd5\uff0c\u8d1f\u8d23\u5904\u7406\u6570\u636e\uff0c\u4f46\u9047\u5230\u4e86\u8fd9\u6837\u7684\u95ee\u9898\uff1astore \u65b9\u6cd5\u91cc data \u6709\u503c\uff0c\u4f46\u662f\u5728\u9875\u9762\u4e0a\u83b7\u53d6\u5230\u7684\u5374\u662f null\u3002<\/p>\n<p><strong>\u95ee\u9898\u539f\u56e0<\/strong><\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u901a\u5e38\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u5f15\u8d77\u7684\uff1a<\/p>\n<p>\u5728 store \u65b9\u6cd5\u4e2d\uff0c\u6ca1\u6709\u6b63\u786e\u8fd4\u56de promise.resolve(data) \u800c\u662f\u8fd4\u56de\u4e86\u5176\u4ed6\u5185\u5bb9\u3002promises \u7528\u4e8e\u8868\u793a\u4e00\u4e2a\u5f02\u6b65\u64cd\u4f5c\uff0c\u5728\u5b83\u4eec\u5b8c\u6210\u4e4b\u524d\u65e0\u6cd5\u83b7\u53d6\u5176\u7ed3\u679c\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u9700\u8981\u786e\u4fdd\u5728 store \u65b9\u6cd5\u4e2d\u6b63\u786e\u8fd4\u56de promise.resolve(data)\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>store() {\n  return this.afterLoginAction(xxx).then(data =&gt; {\n    return Promise.resolve(data);\n  })\n}<\/pre>\n<p>\u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u5728\u9875\u9762\u4e0a\u83b7\u53d6\u5230 store \u65b9\u6cd5\u4e2d data \u7684\u503c\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aVuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   win7\u600e\u4e48\u963b\u6b62\u5e7f\u544a\u5f39\u7a97\u51fa\u73b0 win7\u7981\u6b62\u4e00\u5207\u5f39\u7a97\u5e7f\u544a\u6559\u7a0b\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Vuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f \u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587\u300aVuex store \u4e2d data \u4e3a\u4ec0\u4e48\u8fd4\u56de null\uff1f\u300b\u4e3b\u8981\u8bb2\u89e3\u4e86\u7b49\u7b49\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6211\u4f1a\u5728\u7c73\u4e91\u4e2d\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u5e76\u79ef\u6781\u7559\u8a00\u5efa\u8bae\u3002\u4e0b\u9762\u5c31\u5148\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u672c\u7bc7\u6b63\u6587\u5185\u5bb9\u5427\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01 vuex store \u7684 data \u8fd4\u56de\u7ed3\u679c\u4e3a null \u7684\u539f\u56e0 \u5728 vuex store \u4e2d\u5b9a\u4e49\u7684 action \u91cc\u6709\u4e00\u4e2a store \u65b9\u6cd5\uff0c\u8d1f\u8d23\u5904\u7406\u6570\u636e\uff0c\u4f46\u9047\u5230\u4e86\u8fd9\u6837\u7684\u95ee\u9898\uff1astore \u65b9\u6cd5\u91cc data \u6709\u503c\uff0c\u4f46\u662f\u5728\u9875\u9762\u4e0a\u83b7\u53d6\u5230\u7684\u5374\u662f null\u3002 \u95ee\u9898\u539f\u56e0 \u8fd9\u4e2a\u95ee\u9898\u901a\u5e38\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u5f15\u8d77\u7684\uff1a \u5728 store \u65b9\u6cd5\u4e2d\uff0c\u6ca1\u6709\u6b63\u786e\u8fd4\u56de promise.resolve(data) \u800c\u662f\u8fd4\u56de\u4e86\u5176\u4ed6\u5185\u5bb9\u3002promises \u7528\u4e8e\u8868\u793a\u4e00\u4e2a\u5f02\u6b65\u64cd\u4f5c\uff0c\u5728\u5b83\u4eec\u5b8c\u6210\u4e4b\u524d\u65e0\u6cd5\u83b7\u53d6\u5176\u7ed3\u679c\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u9700\u8981\u786e\u4fdd\u5728 store \u65b9\u6cd5\u4e2d\u6b63\u786e\u8fd4\u56de promise.resolve(data)\uff0c\u5982\u4e0b\u6240\u793a\uff1a store() { return this.afterLoginAction(xxx).then(data =&gt; { return Promise.resolve(data); }) } \u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u5728\u9875\u9762\u4e0a\u83b7\u53d6\u5230 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53493","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53493"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53493\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}