{"id":8623,"date":"2023-11-28T20:33:04","date_gmt":"2023-11-28T12:33:04","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8623"},"modified":"2023-12-02T23:10:56","modified_gmt":"2023-12-02T15:10:56","slug":"vue-zhong-jie-shi-yi-xiajs-de-zhan-kai-cao-zuo-fu","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/vue-zhong-jie-shi-yi-xiajs-de-zhan-kai-cao-zuo-fu\/","title":{"rendered":"Vue \u4e2d\u89e3\u91ca\u4e00\u4e0b JS \u7684\u5c55\u5f00\u64cd\u4f5c\u7b26\uff1f"},"content":{"rendered":"<p>\u5c55\u5f00\u64cd\u4f5c\u7b26\uff08Spread Operator\uff09\u662f JavaScript \u4e2d\u7684\u4e00\u4e2a\u8bed\u6cd5\uff0c\u7528\u4e09\u4e2a\u70b9\uff08<code>...<\/code>\uff09\u8868\u793a\u3002\u5728 Vue \u4e2d\uff0c\u5c55\u5f00\u64cd\u4f5c\u7b26\u5e38\u7528\u4e8e\u5bf9\u8c61\u3001\u6570\u7ec4\u7b49\u6570\u636e\u7ed3\u6784\u7684\u64cd\u4f5c\uff0c\u5b83\u53ef\u4ee5\u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61\uff08\u5982\u6570\u7ec4\u3001\u5bf9\u8c61\u3001\u5b57\u7b26\u4e32\u7b49\uff09\u5c55\u5f00\u4e3a\u5176\u4ed6\u7ed3\u6784\uff0c\u6216\u8005\u5728\u51fd\u6570\u8c03\u7528\u6216\u6570\u7ec4\/\u5bf9\u8c61\u5b57\u9762\u91cf\u4e2d\u4f5c\u4e3a\u53c2\u6570\u4f7f\u7528\u3002<\/p>\n<h3><a id=\"%E5%9C%A8%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E4%BD%BF%E7%94%A8%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u6570\u7ec4\u4e2d\u7684\u4f7f\u7528\uff1a<\/h3>\n<pre><code class=\"language-javascript\">const array = [1, 2, 3];\nconst newArray = [...array]; \/\/ \u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u7684\u6d45\u62f7\u8d1d\n<\/code><\/pre>\n<p>\u5728\u6570\u7ec4\u4e2d\uff0c\u5c55\u5f00\u64cd\u4f5c\u7b26\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u7684\u6d45\u62f7\u8d1d\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5408\u5e76\u6570\u7ec4\uff1a<\/p>\n<pre><code class=\"language-javascript\">const array1 = [1, 2, 3];\nconst array2 = [4, 5, 6];\nconst mergedArray = [...array1, ...array2]; \/\/ \u5408\u5e76\u4e24\u4e2a\u6570\u7ec4\n<\/code><\/pre>\n<h3><a id=\"%E5%9C%A8%E5%AF%B9%E8%B1%A1%E4%B8%AD%E7%9A%84%E4%BD%BF%E7%94%A8%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u5bf9\u8c61\u4e2d\u7684\u4f7f\u7528\uff1a<\/h3>\n<pre><code class=\"language-javascript\">const obj = { a: 1, b: 2 };\nconst newObj = { ...obj }; \/\/ \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u7684\u6d45\u62f7\u8d1d\n<\/code><\/pre>\n<p>\u5728\u5bf9\u8c61\u4e2d\uff0c\u5c55\u5f00\u64cd\u4f5c\u7b26\u540c\u6837\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u7684\u6d45\u62f7\u8d1d\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5408\u5e76\u5bf9\u8c61\uff1a<\/p>\n<pre><code class=\"language-javascript\">const obj1 = { a: 1, b: 2 };\nconst obj2 = { c: 3, d: 4 };\nconst mergedObj = { ...obj1, ...obj2 }; \/\/ \u5408\u5e76\u4e24\u4e2a\u5bf9\u8c61\n<\/code><\/pre>\n<h3><a id=\"%E5%9C%A8%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8%E4%B8%AD%E7%9A%84%E4%BD%BF%E7%94%A8%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u51fd\u6570\u8c03\u7528\u4e2d\u7684\u4f7f\u7528\uff1a<\/h3>\n<pre><code class=\"language-javascript\">function myFunction(x, y, z) {\n  \/\/ ...\n}\n\nconst args = [0, 1, 2];\nmyFunction(...args); \/\/ \u5c06\u6570\u7ec4\u7684\u5143\u7d20\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570\u4f20\u5165\n<\/code><\/pre>\n<p>\u5c55\u5f00\u64cd\u4f5c\u7b26\u4e5f\u53ef\u4ee5\u7528\u4e8e\u51fd\u6570\u8c03\u7528\u4e2d\uff0c\u5c06\u6570\u7ec4\u7684\u5143\u7d20\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570\u4f20\u5165\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u5c55\u5f00\u64cd\u4f5c\u7b26\u63d0\u4f9b\u4e86\u4e00\u79cd\u65b9\u4fbf\u7684\u65b9\u5f0f\u6765\u5c55\u5f00\u53ef\u8fed\u4ee3\u5bf9\u8c61\uff0c\u7528\u4e8e\u521b\u5efa\u62f7\u8d1d\u3001\u5408\u5e76\u6570\u7ec4\u6216\u5bf9\u8c61\u3001\u51fd\u6570\u53c2\u6570\u4f20\u9012\u7b49\u573a\u666f\uff0c\u4f7f\u5f97\u4ee3\u7801\u66f4\u7b80\u6d01\u3001\u6613\u8bfb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c55\u5f00\u64cd\u4f5c\u7b26\uff08Spread Operator\uff09\u662f JavaScript \u4e2d\u7684\u4e00\u4e2a\u8bed\u6cd5\uff0c\u7528\u4e09\u4e2a\u70b9\uff08&#8230;\uff09\u8868\u793a\u3002\u5728 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114],"tags":[],"class_list":["post-8623","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=8623"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8623\/revisions"}],"predecessor-version":[{"id":14142,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8623\/revisions\/14142"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8623"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}