{"id":571,"date":"2023-12-26T10:49:34","date_gmt":"2023-12-26T02:49:34","guid":{"rendered":"http:\/\/ericw.top\/?p=571"},"modified":"2024-01-02T09:26:07","modified_gmt":"2024-01-02T01:26:07","slug":"vue-%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f","status":"publish","type":"post","link":"http:\/\/ericw.top\/?p=571","title":{"rendered":"Vue \u751f\u547d\u5468\u671f"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"toc-0\">Vue \u751f\u547d\u5468\u671f<\/h1>\n\n\n\n<p><strong>\u601d\u8003\uff1a<\/strong>\u4ec0\u4e48\u65f6\u5019\u53ef\u4ee5\u53d1\u9001<strong>\u521d\u59cb\u5316\u6e32\u67d3\u8bf7\u6c42<\/strong>\u3002\u4ec0\u4e48\u65f6\u5019\u5f00\u59cb\u64cd\u4f5c<strong>dom<\/strong><\/p>\n\n\n\n<p><strong>Vue\u751f\u547d\u5468\u671f\uff1a<\/strong>\u4e00\u4e2aVue\u5b9e\u4f8b\u4ece<strong>\u521b\u5efa<\/strong>\u5230<strong>\u9500\u6bc1<\/strong>\u7684\u6574\u4e2a\u8fc7\u7a0b<\/p>\n\n\n\n<p><strong>\u751f\u547d\u5468\u671f\u7684\u56db\u4e2a\u9636\u6bb5\uff1a<\/strong>1 \u521b\u5efa  2 \u6302\u8f7d  3 \u66f4\u65b0  4 \u9500\u6bc1<\/p>\n\n\n\n<p>1\u3001<strong>\u521b\u5efa\u9636\u6bb5\uff1a<\/strong>\u8fdb\u884c\u521d\u59cb\u5316\u5de5\u4f5c\uff0c\u54cd\u5e94\u5f0f\u6570\u636e<\/p>\n\n\n\n<p>2\u3001<strong>\u6302\u8f7d\u9636\u6bb5\uff1a<\/strong>\u6e32\u67d3\u6a21\u677f<\/p>\n\n\n\n<p>3\u3001<strong>\u66f4\u65b0\u9636\u6bb5\uff1a<\/strong>\u7528\u6237\u4f7f\u7528\u7684\u5faa\u73af\uff08<strong>\u6570\u636e\u4fee\u6539\uff0c\u89c6\u56fe\u66f4\u65b0<\/strong>\uff09\u591a\u6b21\u6267\u884c\u3002<\/p>\n\n\n\n<p>4\u3001<strong>\u9500\u6bc1\u9636\u6bb5\uff1a<\/strong>\u9500\u6bc1\u5b9e\u4f8b<\/p>\n\n\n\n<p><strong>\u56de\u7b54\uff1a<\/strong> <strong>\u521b\u5efa\u9636\u6bb5\u53ef\u4ee5\u53d1\u9001\u521d\u59cb\u5316\u6e32\u67d3\u8bf7\u6c42\u3002\u6302\u8f7d\u9636\u6bb5\u7ed3\u675f\u4e4b\u540e\u5f00\u59cb\u64cd\u4f5cdom<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"188\" src=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555724728-1024x188.png\" alt=\"\" class=\"wp-image-573\" srcset=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555724728-1024x188.png 1024w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555724728-300x55.png 300w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555724728-768x141.png 768w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555724728.png 1381w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-1\">Vue\u751f\u547d\u5468\u671f\u51fd\u6570\uff08\u94a9\u5b50\u51fd\u6570\uff09<\/h2>\n\n\n\n<p>Vue\u751f\u547d\u5468\u671f\u8fc7\u7a0b\u4e2d\uff0c\u4f1a<strong>\u81ea\u52a8\u8fd0\u884c\u4e00\u4e9b\u51fd\u6570<\/strong>\uff0c\u88ab\u79f0\u4e3a<strong>\u3010\u751f\u547d\u5468\u671f\u94a9\u5b50\u3011<\/strong>\u2192 \u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u5728<strong>\u3010\u7279\u5b9a\u9636\u6bb5\u3011<\/strong>\u8fd0\u884c<strong>\u81ea\u5df1\u7684\u4ee3\u7801<\/strong>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"356\" src=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555791756-1024x356.png\" alt=\"\" class=\"wp-image-574\" srcset=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555791756-1024x356.png 1024w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555791756-300x104.png 300w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555791756-768x267.png 768w, http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1703555791756.png 1348w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >  &lt;div id=&quot;app&quot;&gt;\n    &lt;h3&gt;{{ title }}&lt;\/h3&gt;\n    &lt;div&gt;\n      &lt;button @click=&quot;count--&quot;&gt;-&lt;\/button&gt;\n      &lt;span&gt;{{ count }}&lt;\/span&gt;\n      &lt;button @click=&quot;count++&quot;&gt;+&lt;\/button&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n  &lt;script src=&quot;https:\/\/cdn.jsdelivr.net\/npm\/vue@2\/dist\/vue.js&quot;&gt;&lt;\/script&gt;\n  &lt;script&gt;\n    const app = new Vue({\n      el: &#039;#app&#039;,\n      data: {\n        count: 100,\n        title: &#039;\u8ba1\u6570\u5668&#039;\n      },\n      \/\/ 1. \u521b\u5efa\u9636\u6bb5\uff08\u51c6\u5907\u6570\u636e\uff09\n      beforeCreate() {\n        console.log(&#039;beforeCreate \u54cd\u5e94\u5f0f\u6570\u636e\u51c6\u5907\u597d\u4e4b\u524d&#039;, this.count)\n      },\n      created() {\n        console.log(&#039;created \u54cd\u5e94\u5f0f\u6570\u636e\u51c6\u5907\u597d\u4e4b\u540e&#039;, this.count)\n        \/\/ this.\u6570\u636e\u540d = \u8bf7\u6c42\u56de\u6765\u7684\u6570\u636e\n        \/\/ \u53ef\u4ee5\u5f00\u59cb\u53d1\u9001\u521d\u59cb\u5316\u6e32\u67d3\u7684\u8bf7\u6c42\u4e86\n      },\n\n      \/\/ 2. \u6302\u8f7d\u9636\u6bb5\uff08\u6e32\u67d3\u6a21\u677f\uff09\n      beforeMount() {\n        console.log(&#039;beforeMount \u6a21\u677f\u6e32\u67d3\u4e4b\u524d&#039;, document.querySelector(&#039;h3&#039;).innerHTML)\n      },\n      mounted() {\n        console.log(&#039;mounted \u6a21\u677f\u6e32\u67d3\u4e4b\u540e&#039;, document.querySelector(&#039;h3&#039;).innerHTML)\n        \/\/ \u53ef\u4ee5\u5f00\u59cb\u64cd\u4f5cdom\u4e86\n      },\n\n      \/\/ 3. \u66f4\u65b0\u9636\u6bb5(\u4fee\u6539\u6570\u636e \u2192 \u66f4\u65b0\u89c6\u56fe)\n      beforeUpdate() {\n        console.log(&#039;beforeUpdate \u6570\u636e\u4fee\u6539\u4e86\uff0c\u89c6\u56fe\u8fd8\u6ca1\u66f4\u65b0&#039;, document.querySelector(&#039;span&#039;).innerHTML)\n      },\n      updated() {\n        console.log(&#039;updated \u6570\u636e\u4fee\u6539\u4e86\uff0c\u89c6\u56fe\u5df2\u7ecf\u66f4\u65b0&#039;, document.querySelector(&#039;span&#039;).innerHTML)\n      },\n\n      \/\/ 4. \u5378\u8f7d\u9636\u6bb5\n      beforeDestroy() {\n        console.log(&#039;beforeDestroy, \u5378\u8f7d\u524d&#039;)\n        console.log(&#039;\u6e05\u9664\u6389\u4e00\u4e9bVue\u4ee5\u5916\u7684\u8d44\u6e90\u5360\u7528\uff0c\u5b9a\u65f6\u5668\uff0c\u5ef6\u65f6\u5668...&#039;)\n      },\n      destroyed() {\n        console.log(&#039;destroyed\uff0c\u5378\u8f7d\u540e&#039;)\n      }\n    })\n  &lt;\/script&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u751f\u547d\u5468\u671f \u601d\u8003\uff1a\u4ec0\u4e48\u65f6\u5019\u53ef\u4ee5\u53d1\u9001\u521d\u59cb\u5316\u6e32\u67d3\u8bf7\u6c42\u3002\u4ec0\u4e48\u65f6\u5019\u5f00\u59cb\u64cd\u4f5cdom Vue\u751f\u547d\u5468\u671f\uff1a\u4e00\u4e2aVue\u5b9e\u4f8b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,5],"tags":[],"_links":{"self":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/571"}],"collection":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=571"}],"version-history":[{"count":3,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":589,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/571\/revisions\/589"}],"wp:attachment":[{"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}