{"id":1685,"date":"2024-11-10T15:49:10","date_gmt":"2024-11-10T07:49:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1685\/"},"modified":"2024-11-10T15:49:10","modified_gmt":"2024-11-10T07:49:10","slug":"vue-%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bc%a0%e9%80%92-map-%e5%8f%98%e9%87%8f%e7%bb%99%e5%ad%90%e7%bb%84%e4%bb%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1685\/","title":{"rendered":"Vue \u4e2d\u5982\u4f55\u4f20\u9012 Map \u53d8\u91cf\u7ed9\u5b50\u7ec4\u4ef6\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173053512420193.jpg\" class=\"aligncenter\" title=\"Vue \u4e2d\u5982\u4f55\u4f20\u9012 Map \u53d8\u91cf\u7ed9\u5b50\u7ec4\u4ef6\uff1f\u63d2\u56fe\" alt=\"Vue \u4e2d\u5982\u4f55\u4f20\u9012 Map \u53d8\u91cf\u7ed9\u5b50\u7ec4\u4ef6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u4e2d map \u53d8\u91cf\u7684\u4f20\u9012<\/strong><\/p>\n<p>\u5728 Vue \u4e2d\u5b9a\u4e49\u4e00\u4e2a Map \u7c7b\u578b\u7684\u53d8\u91cf\u5e76\u5c06\u5176\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u62a5\u9519\u3002\u672c\u6587\u91cd\u70b9\u5206\u6790\u5982\u4f55\u89e3\u51b3\u7236\u7ec4\u4ef6\u5411\u5b50\u7ec4\u4ef6\u4f20\u9012 Map \u53d8\u91cf\u7684\u95ee\u9898\u3002<\/p>\n<p><strong>\u9519\u8bef\u793a\u4f8b<\/strong><\/p>\n<p>\u5047\u8bbe\u7236\u7ec4\u4ef6\u6709\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>data() {\n  return {\n    roomPictureList: new Map()\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5b50\u7ec4\u4ef6\u6709\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>props: ['roomPictureList']<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u7236\u7ec4\u4ef6\u4e2d\u7684 roomPictureList \u53d8\u91cf\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u540e\uff0c\u4f1a\u5728\u63a7\u5236\u53f0\u4e2d\u51fa\u73b0\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre>[Vue warn]: Unhandled error during Vue render: TypeError: item.tap is not a function<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9519\u8bef\u539f\u56e0<\/strong><\/p>\n<p>\u8be5\u9519\u8bef\u7684\u539f\u56e0\u662f Vue \u65e0\u6cd5\u5904\u7406 Map \u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\u3002\u5728 Vue \u4e2d\uff0c\u54cd\u5e94\u5f0f\u6570\u636e\u5fc5\u987b\u662f pln JavaScript \u5bf9\u8c61\u6216\u6570\u7ec4\u3002\u800c Map \u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u5bf9\u8c61\uff0c\u5177\u6709\u4e0d\u540c\u7684\u904d\u5386\u548c\u67e5\u627e\u884c\u4e3a\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06 Map \u53d8\u91cf\u8f6c\u6362\u4e3a\u53ef\u88ab Vue \u5904\u7406\u7684\u6570\u636e\u7ed3\u6784\u3002\u4e00\u79cd\u65b9\u6cd5\u662f\u5c06 Map \u8f6c\u6362\u4e3a\u4e00\u4e2a\u666e\u901a\u5bf9\u8c61\uff1a<\/p>\n<pre>data() {\n  return {\n    roomPictureList: Object.fromEntries(new Map())\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u5c06 Map \u8bbe\u7f6e\u4e3a null\uff0c\u56e0\u4e3a Vue \u53ef\u4ee5\u5904\u7406 null \u503c\uff1a<\/p>\n<pre>data() {\n  return {\n    roomPictureList: null\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06 roomPictureList \u53d8\u91cf\u4fee\u6539\u4e3a\u4ee5\u4e0b\u4ee3\u7801\u4e4b\u4e00\u540e\uff0c\u5373\u53ef\u6210\u529f\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\uff0c\u5e76\u907f\u514d\u62a5\u9519\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue \u4e2d\u5982\u4f55\u4f20\u9012 Map \u53d8\u91cf\u7ed9\u5b50\u7ec4\u4ef6\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>\u4e2d map \u53d8\u91cf\u7684\u4f20\u9012 \u5728 Vue \u4e2d\u5b9a\u4e49\u4e00\u4e2a Map \u7c7b\u578b\u7684\u53d8\u91cf\u5e76\u5c06\u5176\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u62a5\u9519\u3002\u672c\u6587\u91cd\u70b9\u5206\u6790\u5982\u4f55\u89e3\u51b3\u7236\u7ec4\u4ef6\u5411\u5b50\u7ec4\u4ef6\u4f20\u9012 Map \u53d8\u91cf\u7684\u95ee\u9898\u3002 \u9519\u8bef\u793a\u4f8b \u5047\u8bbe\u7236\u7ec4\u4ef6\u6709\u4ee5\u4e0b\u4ee3\u7801\uff1a data() { return { roomPictureList: new Map() } } \u767b\u5f55\u540e\u590d\u5236 \u5b50\u7ec4\u4ef6\u6709\u4ee5\u4e0b\u4ee3\u7801\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b props: [&#8216;roomPictureList&#8217;] \u767b\u5f55\u540e\u590d\u5236 \u5c06\u7236\u7ec4\u4ef6\u4e2d\u7684 roomPictureList \u53d8\u91cf\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u540e\uff0c\u4f1a\u5728\u63a7\u5236\u53f0\u4e2d\u51fa\u73b0\u5982\u4e0b\u9519\u8bef\uff1a [Vue warn]: Unhandled error during Vue render: TypeError: item.tap is not a function \u767b\u5f55\u540e\u590d\u5236 \u9519\u8bef\u539f\u56e0 \u8be5\u9519\u8bef\u7684\u539f\u56e0\u662f Vue \u65e0\u6cd5\u5904\u7406 Map \u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\u3002\u5728 Vue \u4e2d\uff0c\u54cd\u5e94\u5f0f\u6570\u636e\u5fc5\u987b\u662f pln JavaScript \u5bf9\u8c61\u6216\u6570\u7ec4\u3002\u800c [&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-1685","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1685","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=1685"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1685\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}