{"id":1727,"date":"2024-11-10T12:38:29","date_gmt":"2024-11-10T04:38:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1727\/"},"modified":"2024-11-10T12:38:29","modified_gmt":"2024-11-10T04:38:29","slug":"vue-%e5%ad%90%e7%bb%84%e4%bb%b6%e5%a6%82%e4%bd%95%e6%8e%a5%e6%94%b6%e7%88%b6%e7%bb%84%e4%bb%b6%e4%bc%a0%e9%80%92%e7%9a%84-map-%e5%8f%98%e9%87%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1727\/","title":{"rendered":"Vue \u5b50\u7ec4\u4ef6\u5982\u4f55\u63a5\u6536\u7236\u7ec4\u4ef6\u4f20\u9012\u7684 Map \u53d8\u91cf\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173054434790281.jpg\" class=\"aligncenter\" title=\"Vue \u5b50\u7ec4\u4ef6\u5982\u4f55\u63a5\u6536\u7236\u7ec4\u4ef6\u4f20\u9012\u7684 Map \u53d8\u91cf\uff1f\u63d2\u56fe\" alt=\"Vue \u5b50\u7ec4\u4ef6\u5982\u4f55\u63a5\u6536\u7236\u7ec4\u4ef6\u4f20\u9012\u7684 Map \u53d8\u91cf\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5411  \u5b50\u7ec4\u4ef6\u4f20\u9012 map \u53d8\u91cf<\/strong><\/p>\n<p>\u5728 Vue \u4e2d\uff0c\u7236\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7 props \u5411\u5b50\u7ec4\u4ef6\u4f20\u9012\u6570\u636e\u3002\u4f46\u662f\uff0c\u5f53\u8981\u4f20\u9012\u4e00\u4e2a Map \u7c7b\u578b\u7684\u53d8\u91cf\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u62a5\u9519\u3002<\/p>\n<p><strong>\u95ee\u9898\u8868\u73b0\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>\u8d4b\u503c\uff1a<\/p>\n<pre>data() {\n  return {\n    roomPictureList: new Map()\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u4f20\u9012\uff1a \u5c06 roomPictureList \u901a\u8fc7 props \u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6<\/li>\n<li>\n<p>\u63a7\u5236\u53f0\u62a5\u9519\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>TypeError: Supplied property \"roomPictureList\" was not valid. Vue received a value that was not compatible with the expected prop type: Map.<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u95ee\u9898\u51fa\u5728 roomPictureList \u7684\u521d\u59cb\u503c\u662f\u4e00\u4e2a\u7a7a\u5bf9\u8c61\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06\u5176\u6539\u6210 null\uff1a<\/p>\n<pre>data() {\n  return {\n    roomPictureList: null\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\uff0c\u5728\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u65f6\uff0cVue \u4fbf\u80fd\u591f\u6b63\u786e\u8bc6\u522b\u5e76\u63a5\u6536 Map \u53d8\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue \u5b50\u7ec4\u4ef6\u5982\u4f55\u63a5\u6536\u7236\u7ec4\u4ef6\u4f20\u9012\u7684 Map \u53d8\u91cf\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5411 \u5b50\u7ec4\u4ef6\u4f20\u9012 map \u53d8\u91cf \u5728 Vue \u4e2d\uff0c\u7236\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7 props \u5411\u5b50\u7ec4\u4ef6\u4f20\u9012\u6570\u636e\u3002\u4f46\u662f\uff0c\u5f53\u8981\u4f20\u9012\u4e00\u4e2a Map \u7c7b\u578b\u7684\u53d8\u91cf\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u62a5\u9519\u3002 \u95ee\u9898\u8868\u73b0\uff1a \u8d4b\u503c\uff1a data() { return { roomPictureList: new Map() } } \u767b\u5f55\u540e\u590d\u5236 \u4f20\u9012\uff1a \u5c06 roomPictureList \u901a\u8fc7 props \u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6 \u63a7\u5236\u53f0\u62a5\u9519\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b TypeError: Supplied property &#8220;roomPictureList&#8221; was not valid. Vue received a value that was not compatible with the expected prop type: Map. \u767b\u5f55\u540e\u590d\u5236 \u89e3\u51b3\u65b9\u6848\uff1a \u95ee\u9898\u51fa\u5728 [&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-1727","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1727","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=1727"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1727\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}