{"id":789,"date":"2024-07-21T23:24:07","date_gmt":"2024-07-21T15:24:07","guid":{"rendered":"https:\/\/levin.ink\/?p=789"},"modified":"2024-09-08T17:20:15","modified_gmt":"2024-09-08T09:20:15","slug":"vue-5-1-vue-%e5%90%af%e5%8a%a8","status":"publish","type":"post","link":"https:\/\/levin.ink\/?p=789","title":{"rendered":"VUE &#8211; 6-1 VUE \u542f\u52a8"},"content":{"rendered":"<h1>Introduce<\/h1>\n<h1>\u4f7f\u7528<\/h1>\n<p>\u4f7f\u7528 vue \u7684\u4e24\u79cd\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\u5f15\u5165 vue \u7684 js \u6587\u4ef6<\/li>\n<li>\u811a\u624b\u67b6\n<ul>\n<li>\u5b98\u65b9\u811a\u624b\u67b6 vue-cli<\/li>\n<li>\u6c11\u95f4\u811a\u624b\u67b6 \u5982 webpack-simple<\/li>\n<li>\u624b\u52a8\u642d\u5efa<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Hello\uff01<\/h2>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &lt;title&gt;Document&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;div id=&quot;app&quot;&gt;\n        &lt;!-- \u754c\u9762\u6a21\u677f --&gt;\n        &lt;!-- mustache: {{js \u8868\u8fbe\u5f0f}} --&gt;\n        &lt;h1&gt;This is title: {{title}}&lt;\/h1&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        \/\/ vm: Vue \u5b9e\u4f8b\n        let vm = new Vue({\/\/ \u914d\u7f6e\n            \/\/ el(element): css \u9009\u62e9\u5668\n            el: '#app',\n            \/\/ data: \u548c\u754c\u9762\u76f8\u5173\u7684\u6570\u636e\n            data: {\n                message: 'Hello Vue.js!',\n                title: 'Hello!'\n            }\n        })\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n<p>\u5728\u5f00\u53d1\u8005\u63a7\u5236\u53f0\u4e2d\u53ef\u901a\u8fc7\u53d8\u91cf\u8bbf\u95ee\u5e76\u4fee\u6539\u5185\u5bb9\u3002<br \/>\n<div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/levin.ink\/wp-content\/uploads\/2024\/07\/Pasted-image-20240705231651.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/levin.ink\/wp-content\/uploads\/2024\/07\/Pasted-image-20240705231651.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"Pasted image 20240705231651.png\"><\/div><br \/>\n\u6570\u636e\u53d8\u52a8\uff0cVUE\u611f\u77e5\u5230\u6570\u636e\u53d8\u5316\uff0c\u91cd\u6e32\u67d3\uff08\u6570\u636e\u54cd\u5e94\u5f0f\uff09\u3002<br \/>\n<div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/levin.ink\/wp-content\/uploads\/2024\/07\/Pasted-image-20240705231802.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/levin.ink\/wp-content\/uploads\/2024\/07\/Pasted-image-20240705231802.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"Pasted image 20240705231802.png\"><\/div><br \/>\nMVVM(Model,View,View Model)\u6a21\u5f0f<\/p>\n<h2>creeper!<\/h2>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n        &lt;!-- \u754c\u9762\u6a21\u677f --&gt;\n        &lt;!-- mustache: {{js \u8868\u8fbe\u5f0f}} --&gt;\n        &lt;h1&gt;{{message}}&lt;\/h1&gt;\n        &lt;ul&gt;\n            &lt;li v-for=&quot;(creep, i) in lists&quot;&gt;\n                {{creep.role}}: \n                &lt;span v-if=&quot;creep.num &gt; 0&quot;&gt;{{creep.num}}&lt;\/span&gt;\n                &lt;span v-else&gt;none&lt;\/span&gt;\n                &lt;button @click=&quot;spawn(i)&quot;&gt;spawn&lt;\/button&gt;\n                &lt;button @click=&quot;kill(i)&quot;&gt;kill&lt;\/button&gt;\n            &lt;\/li&gt;\n        &lt;\/ul&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        \/\/ vm: Vue \u5b9e\u4f8b\n        let vm = new Vue({\/\/ \u914d\u7f6e\n            \/\/ el(element): css \u9009\u62e9\u5668\n            el: '#app',\n            \/\/ data: \u548c\u754c\u9762\u76f8\u5173\u7684\u6570\u636e\n            data: {\n                message: 'Hello Vue.js!',\n                lists: [\n                    {role: 'harvester', num: 2},\n                    {role: 'builder', num: 3},\n                    {role: 'upgrader', num: 4}\n                ]\n            },\n            methods: {\n                \/\/ \u65b9\u6cd5\n                spawn(i) {\n                    \/\/ this \u6307\u4ee3 vm \u5bf9\u8c61\n                    this.lists[i].num++;\n                },\n                kill(i) {\n                    this.lists[i].num--;\n                    if (this.lists[i].num &lt; 0) {\n                        this.lists[i].num = 0;\n                    };\n                }\n            }\n        })\n    &lt;\/script&gt;\n<\/code><\/pre>\n<p>\u6548\u679c\u5982\u4e0b<br \/>\n<img decoding=\"async\" src=\"https:\/\/levin.ink\/wp-content\/uploads\/2024\/07\/Pasted-image-20240705234354.png\" alt=\"Pasted image 20240705234354.png\"><\/p>\n<h1>\u57fa\u7840\u6982\u5ff5<\/h1>\n<h2>ES6 \u4e00\u4e9b\u7279\u6027<\/h2>\n<h3>\u901f\u5199\u5c5e\u6027 \u548c \u901f\u5199\u65b9\u6cd5<\/h3>\n<pre><code class=\"language-js\">let role = harvest;\nlet creep = {\n    role,\n    logic() {\n    }\n}\n\/* \nlet creep = {\n    role: role,\n    logic: function() {\n    }\n}\n*\/\n<\/code><\/pre>\n<h3>\u6a21\u677f\u5b57\u7b26\u4e32<\/h3>\n<pre><code class=\"language-js\">let num = 1;\nlet str = `\u7b2c\u4e00\u884c\n\u7b2c\u4e8c\u884c\n\u7b2c\u4e09\u884c${num}`;\n\n\/\/ let str = '\u7b2c\u4e00\u884c\\n\u7b2c\u4e8c\u884c\\n\u7b2c\u4e09\u884c' + num;\n<\/code><\/pre>\n<h3>\u7bad\u5934\u51fd\u6570<\/h3>\n<p>\u533f\u540d\u51fd\u6570\u90fd\u53ef\u5199\u4e3a\u7bad\u5934\u51fd\u6570...<br \/>\n\u7bad\u5934\u51fd\u6570\u6ca1\u6709\u81ea\u5df1\u7684this\uff0c\u4f7f\u7528\u7bad\u5934\u51fd\u6570\u5b9a\u4e49\u4f4d\u7f6e\u7684this<\/p>\n<h3>\u6a21\u5757\u5316<\/h3>\n<p>\u5e38\u89c1\u6807\u51c6\uff1aCommonJS\u3001ES6 Module\u3001AMD\u3001CMD\u3001UMD<\/p>\n<h2>\u6ce8\u5165<\/h2>\n<p>\u4e4b\u524d\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-js\">\/\/ vm: Vue \u5b9e\u4f8b\nlet vm = new Vue({\n    el: '#app',\n    data: {\n        message: 'Hello Vue.js!',\n        lists: [\n            {role: 'harvester', num: 2},\n            {role: 'builder', num: 3},\n            {role: 'upgrader', num: 4}\n        ]\n    },\n    methods: {\n        \/\/ \u65b9\u6cd5\n        spawn(i) {\n            \/\/ this \u6307\u4ee3 vm \u5bf9\u8c61\n            this.lists[i].num++;\n        },\n        kill(i) {\n            this.lists[i].num--;\n            if (this.lists[i].num &lt; 0) {\n                this.lists[i].num = 0;\n            };\n        }\n    }\n})\n<\/code><\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7vm.message\u6216vm.spawn(NUM)\u8bbf\u95eedata\u6216methods\u4e2d\u7684\u5c5e\u6027\u3002<br \/>\n\u56e0\u4e3adata\u548cmethods\u4e2d\u7684\u5185\u5bb9\u4f1a\u88ab\u76f4\u63a5\u63d0\u53d6\u5230vue\u5b9e\u4f8b\u4e2d\u3002<br \/>\n\u8be5\u8fc7\u7a0b\u79f0\u4e4b\u4e3a\u6ce8\u5165\u3002<br \/>\n\u76ee\u7684\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5b8c\u6210\u6570\u636e\u54cd\u5e94\u5f0f<br \/>\n\u5c06\u4f7f\u7528<code>Object.defineProperty<\/code>\u6216<code>class Proxy<\/code>\u6dfb\u52a0\u5bf9\u6570\u636e\u7684\u76d1\u542c\u3002<br \/>\n\u533a\u522b-&gt;<\/li>\n<li>\u7ed1\u5b9athis<br \/>\n\u6211\u4eec\u5728methods\u4e2d\u7684\u51fd\u6570\u4e2d\u4f7f\u7528\u4e86this\uff0c\u65b9\u4fbf\u51fd\u6570\u4fee\u6539\u8bfb\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n<h2>\u865a\u62df DOM \u6811<\/h2>\n<p>\u4e3a\u4e86\u63d0\u9ad8\u6e32\u67d3\u6548\u7387\uff0cvue\u5c06\u6a21\u677f\u7f16\u8bd1\u6210\u4e3a\u865a\u62dfDOM\u6811\uff0c\u7136\u540e\u518d\u751f\u6210\u771f\u5b9eDOM\u6811\u3002<br \/>\n\u865a\u62dfDOM\u6811\u53ea\u662fjs\u5bf9\u8c61\uff0c\u5e76\u672a\u5c55\u793a\u5230\u9875\u9762\u4e0a\uff0c\u771f\u5b9eDOM\u6811\u4e5f\u662fjs\u5bf9\u8c61\uff0c\u4f46\u548c\u9875\u9762\u4e0a\u7684\u4fe1\u606f\u76f8\u5173\u3002<\/p>\n<blockquote>\n<p>\u5982\u4f55\u63d0\u9ad8\u6e32\u67d3\u6548\u7387\u7684\uff1a<\/p>\n<ul>\n<li><strong>\u51cf\u5c11\u76f4\u63a5\u64cd\u4f5c\u771f\u5b9eDOM\uff1a<\/strong> \u771f\u5b9eDOM\u64cd\u4f5c\u662f\u76f8\u5bf9\u6602\u8d35\u7684\uff0c\u56e0\u4e3a\u6bcf\u6b21\u66f4\u6539\u90fd\u4f1a\u5f15\u8d77\u6d4f\u89c8\u5668\u7684\u91cd\u6392\u6216\u91cd\u7ed8\u3002\u865a\u62dfDOM\u5145\u5f53\u4e86\u4e00\u4e2a\u4e2d\u95f4\u5c42\uff0c\u5c06\u5bf9DOM\u7684\u66f4\u6539\u805a\u96c6\u5728\u4e00\u8d77\uff0c\u5e76\u4f7f\u7528\u9ad8\u6548\u7684\u7b97\u6cd5\u6765\u6700\u5c0f\u5316\u5b9e\u9645DOM\u7684\u64cd\u4f5c\u6b21\u6570\uff0c\u51cf\u5c11\u6027\u80fd\u5f00\u9500\u3002<\/li>\n<li><strong>\u6279\u91cf\u66f4\u65b0\uff1a<\/strong> \u865a\u62dfDOM\u5c06\u591a\u4e2aDOM\u66f4\u6539\u6279\u91cf\u5904\u7406\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u591a\u6b21\u91cd\u65b0\u6e32\u67d3\u3002\u5728\u66f4\u65b0\u8fc7\u7a0b\u4e2d\uff0c\u865a\u62dfDOM\u4f1a\u8bb0\u5f55\u6240\u6709\u9700\u8981\u66f4\u65b0\u7684\u66f4\u6539\uff0c\u7136\u540e\u4e00\u6b21\u6027\u8fdb\u884c\u5b9e\u9645DOM\u7684\u64cd\u4f5c\uff0c\u4f18\u5316\u6574\u4f53\u6027\u80fd\u3002<\/li>\n<li><strong>Diff\u7b97\u6cd5\uff1a<\/strong> \u865a\u62dfDOM\u4f7f\u7528Diff\u7b97\u6cd5\u6bd4\u8f83\u5148\u524d\u865a\u62dfDOM\u6811\u548c\u5f53\u524d\u865a\u62dfDOM\u6811\u7684\u5dee\u5f02\u3002Diff\u7b97\u6cd5\u80fd\u591f\u9ad8\u6548\u5730\u627e\u51fa\u54ea\u4e9b\u90e8\u5206\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u7136\u540e\u53ea\u66f4\u65b0\u53d1\u751f\u53d8\u5316\u7684\u90e8\u5206\u5230\u771f\u5b9eDOM\uff0c\u800c\u4e0d\u4f1a\u91cd\u65b0\u6e32\u67d3\u6574\u4e2aDOM\u6811\u3002<\/li>\n<li><strong>\u5185\u5b58\u4e2d\u7684\u64cd\u4f5c\uff1a<\/strong> \u865a\u62dfDOM\u5b58\u5728\u4e8eJavaScript\u5185\u5b58\u4e2d\uff0c\u64cd\u4f5c\u66f4\u52a0\u9ad8\u6548\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u5b9e\u9645DOM\u64cd\u4f5c\u6d89\u53ca\u5230\u4e0e\u6d4f\u89c8\u5668\u7684\u4ea4\u4e92\uff0c\u9700\u8981\u6d88\u8017\u66f4\u591a\u7684\u8d44\u6e90\u3002<\/li>\n<li><strong>\u8de8\u5e73\u53f0\u4f18\u52bf\uff1a<\/strong> \u865a\u62dfDOM\u53ef\u4ee5\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u8fd0\u884c\uff0c\u4f8b\u5982\u6d4f\u89c8\u5668\u548c\u670d\u52a1\u5668\u7aef\uff08\u4f8b\u5982React\u4f7f\u7528\u7684React Native\u548cReact Server\uff09\u3002\u8fd9\u79cd\u4e00\u81f4\u6027\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u5171\u4eab\u4ee3\u7801\uff0c\u4ece\u800c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u6027\u80fd\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u53ef\u901a\u8fc7vm._vnode\u8bbf\u95ee\u865a\u62dfDOM\u6811 pe\uff08Pseudo Element\uff09<\/p>\n<pre><code class=\"language-js\">let v1 = vm._vnode;\nvm.title = &quot;123&quot;;\nlet v2 = vm._vnode;\n\nv1 === v2;\n\/\/ false\nv1.elm === v2.elm;\n\/\/ true\n<\/code><\/pre>\n<p>\u56e0\u6b64\uff0c\u5bf9\u4e8e\u63d0\u5347vue\u6548\u7387\u91cd\u70b9\u5728\u4ee5\u4e0b\u4e24\u4e2a\u65b9\u9762\uff1a<\/p>\n<ul>\n<li>\u51cf\u5c11\u65b0\u7684\u865a\u62dfDOM\u6811\u751f\u6210\u3002<\/li>\n<li>\u4fdd\u8bc1\u5bf9\u6bd4\u4e4b\u540e\uff0c\u53ea\u6709\u5fc5\u8981\u7684\u8282\u70b9\u53d8\u5316\u3002<br \/>\nvue\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u65b9\u5f0f\u4fee\u6539\u865a\u62dfDOM\u6811\uff1a<\/li>\n<li>\u76f4\u63a5\u4fee\u6539\u6302\u8f7d\u7684\u5143\u7d20\u5185\u90e8\uff0c\u4f7f\u7528\u5143\u7d20\u7684outerHTML\u4f5c\u4e3a\u6a21\u677f\u3002<\/li>\n<li>\u5728template\u914d\u7f6e\u4e2d\u4e66\u5199\u3002<\/li>\n<li>\u5728render\u914d\u7f6e\u4e2d\u4f7f\u7528\u51fd\u6570\u76f4\u63a5\u521b\u5efa\u865a\u62df\u8282\u70b9\u6811\uff0c\u5b8c\u5168\u8131\u79bb\u6a21\u677f\uff0c\u7701\u7565\u7f16\u8bd1\u6b65\u9aa4\u3002<br \/>\n\u4ece\u4e0a\u5230\u4e0b\u4f18\u5148\u7ea7\u9012\u589e\u3002<br \/>\n\u4e0a\u9762\u7684\u4e09\u4e2a\u65b9\u6cd5\u5176\u5b9e\u672c\u8d28\u76f8\u540c\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n    &lt;&lt;h1&gt;{{message}}&lt;\/h1&gt;\n    &lt;ul&gt;\n        &lt;li v-for=&quot;(creep, i) in lists&quot;&gt;\n            {{creep.role}}\n        &lt;\/li&gt;\n    &lt;\/ul&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<pre><code class=\"language-js\">\/\/ vm: Vue \u5b9e\u4f8b\nlet vm = new Vue({\n    el: '#app',\n    template: `\n       &lt;div&gt;\n             &lt;h1&gt;{{message}}&lt;\/h1&gt;\n             &lt;ul&gt;\n                 &lt;li v-for=&quot;(creep, i) in lists&quot;&gt;\n                     {{creep.role}}\n                 &lt;\/li&gt;\n             &lt;\/ul&gt;\n         &lt;\/div&gt;\n    `,\n    render(h) {\n        return h(&quot;div&quot;, [\n            h(&quot;h1&quot;, this.message),\n            h(&quot;ul&quot;, this.lists.map(creep =&gt; h(&quot;li&quot;, creep.role)))\n        ])\n    },\n\n    data: {\n        ...\n    },\n    methods: {\n        ...\n    }\n})\n<\/code><\/pre>\n<p>\u672c\u8d28\u90fd\u662f\u901a\u8fc7render\u51fd\u6570\u3002\u6570\u636e\u53d8\u5316\u4fbf\u53ef\u91cd\u65b0\u8c03\u7528render\u51fd\u6570\u5c06\u9875\u9762\u66f4\u65b0\u3002<\/p>\n<blockquote>\n<p>\u865a\u62df\u8282\u70b9\u6811\u5fc5\u987b\u662f\u5355\u6839\u7684<br \/>\n\u201c\u6a21\u677f\u53ea\u80fd\u7531\u4e00\u4e2a\u6839\u8282\u70b9\u201d<\/p>\n<\/blockquote>\n<h2>\u6302\u8f7d<\/h2>\n<p>\u5c06\u865a\u62dfDOM\u6811\u751f\u6210\u7684\u771f\u5b9eDOM\u6811\uff0c\u653e\u7f6e\u5230\u67d0\u4e2a\u5143\u7d20\u4f4d\u7f6e\uff08\u66ff\u6362\uff09\uff0c\u79f0\u4e3a\u6302\u8f7d\u3002<br \/>\n\u6302\u8f7d\u7684\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>el\u914d\u7f6e<\/li>\n<li>\u901a\u8fc7\u8c03\u7528vm.$mount(&quot;css\u9009\u62e9\u5668&quot;)<\/li>\n<\/ul>\n<h2>\u5b8c\u6574\u6d41\u7a0b<\/h2>\n<p>\u9996\u6b21\u6e32\u67d3\uff1a\u5b9e\u4f8b\u521b\u5efa -&gt; \u6ce8\u5165 -&gt; \u7f16\u8bd1\u751f\u6210\u865a\u62dfDOM\u6811 -&gt; \u6302\u8f7d -&gt; \u5df2\u6302\u8f7d<br \/>\n\u91cd\u65b0\u6e32\u67d3\uff1a\u6570\u636e\u53d8\u52a8 -&gt; \u91cd\u65b0\u751f\u6210\u65b0DOM\u6811 -&gt; \u5bf9\u6bd4\u65b0\u65e7\u6811\u7684\u5dee\u5f02 -&gt; \u5c06\u5dee\u5f02\u5e94\u7528\u5230\u771f\u5b9eDOM -&gt; \u5b8c\u6210\u6e32\u67d3<\/p>\n<h1>\u6a21\u677f\u8bed\u6cd5 \u4e0e \u8ba1\u7b97\u5c5e\u6027<\/h1>\n<h2>\u6a21\u677f\u8bed\u6cd5<\/h2>\n<h3>\u5185\u5bb9<\/h3>\n<p>\u5143\u7d20\u5185\u5bb9\u4f4d\u7f6e<br \/>\n\u5143\u7d20\u5185\u5bb9\u4e2d\u4f7f\u7528mustache\u6a21\u677f\u5f15\u64ce\u8fdb\u884c\u89e3\u6790<br \/>\nvue\u5c06vue\u5b9e\u4f8b\u7ed1\u5b9a\u5230\u6a21\u677f\u5b57\u7b26\u4e32\u4e0a\uff0c{{title}} \u76f8\u5f53\u4e8e vm.title\u3002<\/p>\n<blockquote>\n<p>\u6a21\u677f\u5f15\u64ce<br \/>\n\u5c06\u4e00\u4e2a\u6a21\u677f\u5b57\u7b26\u4e32\uff0c\u52a0\u4e0a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u8fdb\u884c\u7f16\u8bd1\u5f97\u5230\u4e00\u4e2a\u5b8c\u6574\u5b57\u7b26\u4e32\u3002<\/p>\n<\/blockquote>\n<h3>\u6307\u4ee4<\/h3>\n<p>\u5143\u7d20\u5c5e\u6027\u4f4d\u7f6e<br \/>\n\u6307\u4ee4\u5f71\u54cd\u5143\u7d20\u7684\u6e32\u67d3\u884c\u4e3a\uff0c\u59cb\u7ec8\u4ee5v-\u5f00\u5934<br \/>\n\u57fa\u7840\u6307\u4ee4\uff1a<\/p>\n<ul>\n<li><code>v-for<\/code>: \u5faa\u73af\u6e32\u67d3\u5143\u7d20<\/li>\n<li><code>v-html<\/code>: \u8bbe\u7f6e\u5143\u7d20\u7684innerHTML\uff0c\u4f1a\u5bfc\u81f4\u5143\u7d20\u7684\u6a21\u677f\u5185\u5bb9\u5931\u6548<\/li>\n<li><code>v-on<\/code>: \u6ce8\u518c\u4e8b\u4ef6\n<ul>\n<li>\u5341\u5206\u5e38\u7528\u53ef\u7b80\u5199\u4e3a<code>@<\/code><\/li>\n<li>\u652f\u6301\u4e00\u4e9b\u6307\u4ee4\u4fee\u9970\u7b26\uff0c\u5982<code>prevent<\/code>\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\uff0c<code>stop<\/code>\u963b\u6b62\u5192\u6ce1<\/li>\n<li>\u81ea\u52a8\u4f20\u9012\u53c2\u6570<\/li>\n<\/ul>\n<\/li>\n<li><code>v-bind<\/code>: \u7ed1\u5b9a\u52a8\u6001\u5c5e\u6027\n<ul>\n<li>\u7b80\u5199\u4e3a<code>:<\/code><\/li>\n<\/ul>\n<\/li>\n<li><code>v-show<\/code>: \u63a7\u5236\u5143\u7d20\u53ef\u89c1\u5ea6<\/li>\n<li><code>v-if v-else-if v-else<\/code>: \u63a7\u5236\u5143\u7d20\u751f\u6210<\/li>\n<li><code>v-model<\/code>: \u53cc\u5411\u6570\u636e\u7ed1\u5b9a\n<ul>\n<li>\u662f <code>v-on<\/code> \u548c <code>v-bind<\/code> \u7684\u590d\u5408\u7248<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code class=\"language-html\">&lt;li v-for=&quot;(creep, i) in lists&quot;&gt;{{creep}}&lt;\/li&gt;\n\n\/\/ html: &quot;&lt;p style='color:red'&gt; Hello! &lt;\/p&gt;&quot;\n&lt;h1 v-html=&quot;html&quot;&gt;&lt;\/h1&gt;\n\n&lt;button v-on:click=&quot;spawn(i)&quot;&gt;spawn&lt;\/button&gt;\n&lt;button @click=&quot;spawn(i)&quot;&gt;spawn&lt;\/button&gt;\n\n\/\/ \u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\n&lt;a herf=&quot;&quot; @click.prevent=&quot;console.log&quot;&gt;&lt;\/a&gt;\n\/\/ \u70b9\u51fb\u65f6\u8fd0\u884cconsole.log(e), \u53c2\u6570\u81ea\u52a8\u4f20\u9012\n\/\/ \u624b\u52a8\u4f20\u9012\n&lt;a herf=&quot;&quot; @click.prevent=&quot;console.log($event)&quot;&gt;&lt;\/a&gt;\n\n\/\/ imgUrl: &quot;https:\/\/xxx&quot;\n&lt;img v-bind:src=&quot;imgUrl&quot;\/&gt;\n&lt;img :src=&quot;imgUrl&quot;\/&gt;\n\n\/\/ isShow: true\n&lt;img v-show=&quot;isShow&quot; :src=&quot;imgUrl&quot;\/&gt;\n&lt;button @click=&quot;isShow = !isShow&quot;&gt;&lt;\/button&gt;\n\n&lt;img v-if=&quot;isShow&quot; :src=&quot;imgUrl&quot;\/&gt;\n\n&lt;h1&gt;{{text}}&lt;h1&gt;\n&lt;input type=&quot;text&quot; :value=&quot;text&quot; @input=&quot;text=$event.target.value&quot;&gt;&lt;\/input&gt;\n\n&lt;h1&gt;{{text}}&lt;h1&gt;\n&lt;input type=&quot;text&quot; v-model:value=&quot;text&quot;&gt;&lt;\/input&gt;\n<\/code><\/pre>\n<blockquote>\n<p><code>v-on<\/code>\u4e2d\u4f20\u9012\u7684\u53ef\u4ee5\u662f\u51fd\u6570\u540d\u4e5f\u53ef\u4ee5\u662f\u51fd\u6570\u8c03\u7528<\/p>\n<\/blockquote>\n<blockquote>\n<p><code>v-show<\/code> \u548c <code>v-if ...<\/code> \u7684\u533a\u522b<br \/>\n<code>v-show<\/code> \u53ea\u8bbe\u7f6e <code>display:none<\/code>\uff0c\u5143\u7d20\u4f9d\u65e7\u5b58\u5728<br \/>\n<code>v-if ...<\/code> \u4e0d\u5b58\u5728\u5c31\u771f\u7684\u4e0d\u5b58\u5728\uff0c\u4e0d\u4f1a\u51fa\u73b0\u5728DOM\u4e2d<br \/>\n\u82e5\u9700\u8981\u9891\u7e41\u5207\u6362\u663e\u793a\uff0c\u4f7f\u7528<code>v-show<\/code>\u4e0d\u4f1a\u5f71\u54cd\u5143\u7d20\u7ed3\u6784<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u5176\u4ed6\u6307\u4ee4<\/p>\n<ul>\n<li>v-slot<\/li>\n<li>v-text<\/li>\n<li>v-pre<\/li>\n<li>v-cloak<\/li>\n<li>v-once<\/li>\n<li>\u81ea\u5b9a\u4e49\u6307\u4ee4<\/li>\n<\/ul>\n<\/blockquote>\n<h3>\u7279\u6b8a\u5c5e\u6027<\/h3>\n<p>\u6700\u91cd\u8981\u7684\u7279\u6b8a\u5c5e\u6027 key<br \/>\n\u8003\u8651\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n    &lt;div v-if=&quot;loginMethod==='phone'&quot;&gt;\n        &lt;label&gt;\u624b\u673a\u53f7&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; \/&gt;\n    &lt;\/div&gt;\n    &lt;div v-else&gt;\n        &lt;label&gt;\u90ae\u7bb1&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; \/&gt;\n    &lt;\/div&gt;\n    &lt;button @click=&quot;loginMethod === 'phone' ? loginMethod = 'email' : loginMethod = 'phone'&quot;&gt;\u5207\u6362\u767b\u5f55\u65b9\u5f0f&lt;\/button&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<p>\u5982\u679c\u6211\u4eec\u5c1d\u8bd5\u5728input\u4e2d\u8f93\u5165\u5185\u5bb9\u540e\u5207\u6362\u767b\u5f55\u65b9\u5f0f\uff0c\u4f1a\u53d1\u73b0\u8f93\u5165\u6846\u7684\u5185\u5bb9\u4f9d\u65e7\u4fdd\u7559\uff0c\u4f46\u89c2\u5bdf\u6211\u4eec\u7684\u4ee3\u7801\u4e24\u4e2a\u5e76\u4e0d\u662f\u540c\u4e00\u4e2a\u8f93\u5165\u6846\u3002<br \/>\ndiff\u7b97\u6cd5\u901a\u8fc7\u6bd4\u8f83\u524d\u4e24\u4e2aDOM\u53d1\u73b0\u53ea\u6709label\u53d1\u751f\u53d8\u5316\uff0c\u4fbf\u53ea\u6539\u52a8\u4e86label\uff0c\u5bfc\u81f4input\u5e76\u6ca1\u6709\u53d1\u751f\u4efb\u4f55\u53d8\u5316\u3002<br \/>\nkey\u5c5e\u6027\u53ef\u4ee5\u5e72\u9884diff\u7b97\u6cd5\uff0c\u82e5\u8bbe\u7f6e\u4e86key\u503c\uff0c\u5219\u4f1a\u53ea\u5bf9key\u76f8\u540c\u7684\u8282\u70b9\u8fdb\u884c\u6bd4\u5bf9\uff0c\u82e5key\u503c\u4e0d\u540c\uff0c\u4fbf\u4e0d\u518d\u6bd4\u5bf9\u5143\u7d20\uff0c\u76f4\u63a5\u4fee\u6539\uff08\u65e7\u8282\u70b9\u79fb\u9664\uff0c\u65b0\u8282\u70b9\u6dfb\u52a0\uff09\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n    &lt;div v-if=&quot;loginMethod==='phone'&quot;&gt;\n        &lt;label&gt;\u624b\u673a\u53f7&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; key=&quot;1&quot;\/&gt;\n    &lt;\/div&gt;\n    &lt;div v-else&gt;\n        &lt;label&gt;\u90ae\u7bb1&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; key=&quot;2&quot;\/&gt;\n    &lt;\/div&gt;\n    &lt;button @click=&quot;loginMethod === 'phone' ? loginMethod = 'email' : loginMethod = 'phone'&quot;&gt;\u5207\u6362\u767b\u5f55\u65b9\u5f0f&lt;\/button&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0\u4e0a\u9762\u7684\u60c5\u51b5\u4e86\u3002<br \/>\n\u518d\u8003\u8651\u4ee5\u4e0b\u60c5\u51b5:)<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n    &lt;p v-for=&quot;(v, i) in lists&quot;&gt;\n        {{v}}\n        &lt;button @click=&quot;lists.splice(i, 1)&quot;&gt;delete&lt;\/button&gt;\n    &lt;\/p&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<p>\u901a\u8fc7\u5f00\u53d1\u8005\u63a7\u5236\u53f0\u53ef\u4ee5\u53d1\u73b0\uff0c\u5f53\u6211\u4eec\u5220\u9664\u5176\u4e2d\u4e00\u4e2a\u5143\u7d20\u65f6\uff0c\u53d1\u73b0\u5176\u4ed6\u6ca1\u88ab\u5220\u9664\u7684\u5143\u7d20\u4e5f\u88ab\u66f4\u65b0\u4e86\uff0c\u82e5\u5217\u8868\u8f83\u957f\uff0c\u4f1a\u975e\u5e38\u5f71\u54cd\u6548\u7387\u3002<br \/>\n\u5047\u8bbe\u539f\u6765\u67091\u30012\u30013\u30014\u56db\u4e2a\u8282\u70b9\uff0c\u82e5\u5220\u9664\u7b2c\u4e8c\u4e2a1\u30013\u30014\uff0c\u6bd4\u8f83\u65f6\uff0c1\u548c1\u6bd4\u8f83\uff0c2\u548c3\u6bd4\u8f83\uff0c3\u548c4\u6bd4\u8f83...\u53d1\u73b0\u540e\u9762\u7684\u8282\u70b9\u90fd\u53d8\u5316\u4e86<br \/>\n\u9488\u5bf9\u8fd9\u79cd\u60c5\u51b5\uff0cvue\u5f3a\u70c8\u5efa\u8bae\u7ed9\u6bcf\u4e2a\u5728\u5faa\u73af\u751f\u6210\u7684\u8282\u70b9\u4e0a\u6dfb\u52a0\u4e00\u4e2a\u552f\u4e00\u4e14\u7a33\u5b9a\u7684key\u503c\u3002<br \/>\n\u6dfb\u52a0\u540e\uff0c\u53ea\u4f1a\u6bd4\u8f83key\u76f8\u540c\u7684\u8282\u70b9\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n    &lt;p v-bind:key=&quot;v.id&quot; v-for=&quot;(v, i) in lists&quot;&gt;\n        {{v.value}}\n        &lt;button @click=&quot;lists.splice(i, 1)&quot;&gt;delete&lt;\/button&gt;\n    &lt;\/p&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<blockquote>\n<p>key\u5c5e\u6027\u4e0d\u4f1a\u51fa\u73b0\u5728\u5b9e\u9645dom\u4e2d<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u5176\u4ed6\u7279\u6b8a\u5c5e\u6027<\/p>\n<ul>\n<li>ref<\/li>\n<li>is<\/li>\n<li>slot<\/li>\n<li>slot-scope<\/li>\n<li>scope<\/li>\n<\/ul>\n<\/blockquote>\n<h2>\u8ba1\u7b97\u5c5e\u6027<\/h2>\n<p>\u7c7b\u4f3c getter setter<\/p>\n<pre><code class=\"language-js\">computed: {\n    \/\/ \u4ec5\u8bbf\u95ee\u5668\n    prop() {\n        return ...\n    }\n    \/\/ \u8bbf\u95ee\u5668 + \u8bbe\u7f6e\u5668\n    fullProp: {\n        get() {\n            return ...\n        },\n        set(val) {\n            ...\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u4f8b\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;div id=&quot;app&quot;&gt;\n        &lt;p&gt;firstname: {{firstName}}&lt;\/p&gt;\n        &lt;p&gt;lastname: {{lastName}}&lt;\/p&gt;\n        &lt;p&gt;fullname: {{fullName}}&lt;\/p&gt;\n        &lt;input type=&quot;text&quot; v-model=&quot;fullName&quot;\/&gt;\n    &lt;\/div&gt;\n    &lt;script&gt;\n        let vm = new Vue({\n            el: '#app',\n            data: {\n                firstName: &quot;Lorem&quot;,\n                lastName: &quot;ipsum&quot;\n            },\n            computed: {\n                fullName: {\n                    get() {\n                        return this.firstName + &quot; &quot; + this.lastName;\n                    },\n                    set(val) {\n                        console.log(&quot;1&quot;);\n                        [this.firstName, this.lastName] = val.split(&quot; &quot;);\n                    }\n                }\n            }\n        })\n    &lt;\/script&gt;\n<\/code><\/pre>\n<p>\u8ba1\u7b97\u5c5e\u6027(computed)\u548c\u65b9\u6cd5(method)\u7684\u533a\u522b<\/p>\n<ul>\n<li>\u8ba1\u7b97\u5c5e\u6027\u53ef\u4ee5\u8d4b\u503c\uff0c\u65b9\u6cd5\u4e0d\u884c<\/li>\n<li>\u8ba1\u7b97\u5c5e\u6027\u4f1a\u8fdb\u884c\u7f13\u5b58\uff0c\u4f9d\u8d56\u4e0d\u53d8\uff0c\u4e0d\u4f1a\u91cd\u65b0\u8ba1\u7b97<\/li>\n<li>\u6839\u636e\u5df2\u6709\u6570\u636e\u5f97\u5230\u65b0\u6570\u636e\u7684\u65e0\u53c2\u51fd\u6570\uff0c\u90fd\u5e94\u8be5\u5199\u6210\u8ba1\u7b97\u5c5e\u6027<\/li>\n<\/ul>\n<h1>\u7ec4\u4ef6<\/h1>\n<h2>\u7ec4\u4ef6\u6982\u5ff5<\/h2>\n<p>\u76f4\u63a5\u5c06\u5b8c\u6574\u7f51\u9875\u4f5c\u4e3a\u6574\u4f53\u5f00\u53d1\uff0c\u4f1a\u9047\u5230\u4ee5\u4e0b\u56f0\u96be<\/p>\n<ul>\n<li>\u4ee3\u7801\u51cc\u4e71\u81c3\u80bf<\/li>\n<li>\u4e0d\u6613\u534f\u4f5c<\/li>\n<li>\u96be\u4ee5\u590d\u7528<br \/>\n\u63a8\u8350\u7ec4\u4ef6\u5316\u5f00\u53d1\uff0c\u7ec4\u4ef6\u5316\u5c31\u662f\u628a\u9875\u9762\u4e2d\u7684\u533a\u57df\u529f\u80fd\u7ec6\u5206\uff0c\u6bcf\u4e2a\u533a\u57df\u6210\u4e3a\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u6bcf\u4e2a\u7ec4\u4ef6\u5305\u542b\uff1a<\/li>\n<li>\u529f\u80fd\uff1aJS<\/li>\n<li>\u5185\u5bb9\uff1a\u6a21\u677f<\/li>\n<li>\u6837\u5f0f\uff1aCSS<\/li>\n<\/ul>\n<blockquote>\n<p>CSS\u4ee3\u7801\u9700\u8981\u6784\u5efa\u5de5\u5177\u7684\u652f\u6491<\/p>\n<\/blockquote>\n<h2>\u7ec4\u4ef6\u5f00\u53d1<\/h2>\n<h3>\u521b\u5efa\u7ec4\u4ef6<\/h3>\n<p>\u7ec4\u4ef6\u6839\u636e\u666e\u901a\u7684\u914d\u7f6e\u5bf9\u8c61\u521b\u5efa\uff0c\u53ea\u9700\u5199\u4e00\u4e2a\u914d\u7f6e\u5bf9\u8c61\u5373\u53ef\u5f00\u53d1\u4e00\u4e2a\u7ec4\u4ef6<br \/>\n\u914d\u7f6e\u5bf9\u8c61\u548cvue\u5b9e\u4f8b\u51e0\u4e4e\u4e00\u6837<\/p>\n<pre><code class=\"language-js\">\/\/ \u7ec4\u4ef6\u914d\u7f6e\u5bf9\u8c61\nlet com = {\n    data() {\n        return {\n            \/\/ ...\n        }\n    },\n    methods: {\n        \/\/ ...\n    },\n    computed: {\n        \/\/ ...\n    },\n    template: <code>...<\/code>\n}\n<\/code><\/pre>\n<p>\u7ec4\u4ef6\u914d\u7f6e\u5bf9\u8c61\u548cvue\u5b9e\u4f8b\u6709\u4ee5\u4e0b\u5dee\u5f02\uff1a<\/p>\n<ul>\n<li>\u65e0el<\/li>\n<li>data\u5fc5\u987b\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u51fd\u6570\u8fd4\u56de\u7684\u5bf9\u8c61\u4f5c\u4e3a\u6570\u636e<\/li>\n<li>\u6ca1\u6709el\u914d\u7f6e\uff0c\u7ec4\u4ef6\u7684\u865a\u62dfDOM\u6811\u5fc5\u987b\u5b9a\u4e49\u5728template\u6216render\u4e2d<\/li>\n<\/ul>\n<h3>\u6ce8\u518c\u7ec4\u4ef6<\/h3>\n<p>\u4e24\u79cd\u6ce8\u518c\u65b9\u5f0f\uff0c\u5168\u5c40\u6ce8\u518c\uff0c\u5c40\u90e8\u6ce8\u518c<\/p>\n<h4>\u5168\u5c40\u6ce8\u518c<\/h4>\n<p>\u6574\u4e2a\u5e94\u7528\u4e2d\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u4f7f\u7528\u8be5\u7ec4\u4ef6<br \/>\n\u5168\u5c40\u6ce8\u518c\u65b9\u5f0f\uff1a<\/p>\n<pre><code class=\"language-js\">\/\/ \u53c2\u65701\uff1a\u7ec4\u4ef6\u540d\u79f0\uff0c\u4f7f\u7528\u7ec4\u4ef6\u65f6\u7684\u540d\u79f0\n\/\/ \u53c2\u65702\uff1a\u7ec4\u4ef6\u914d\u7f6e\u5bf9\u8c61\n\/\/ \u8fd0\u884c\u540e\u4fbf\u53ef\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u7ec4\u4ef6\nVue.component(&quot;MyComp&quot;, myComp)\n<\/code><\/pre>\n<pre><code class=\"language-html\">\/\/ \u4f7f\u7528\n&lt;MyComp \/&gt;\n&lt;MyComp&gt;&lt;\/MyComp&gt;\n\/\/ \u6216\n&lt;my-comp \/&gt;\n&lt;my-comp&gt;&lt;\/my-comp&gt;\n<\/code><\/pre>\n<blockquote>\n<p>\u5927\u591a\u6570\u65f6\u5019\u4e0d\u9700\u8981\u5168\u5c40\u6ce8\u518c\uff0c\u4e00\u822c\u4e0d\u5efa\u8bae<\/p>\n<\/blockquote>\n<h4>\u5c40\u90e8\u6ce8\u518c<\/h4>\n<p>\u5728\u54ea\u7528\u5728\u54ea\u6ce8\u518c<\/p>\n<pre><code class=\"language-js\">let vm = new Vue({\n    el:...\n    ...\n    components {\n        \/\/ \u5c5e\u6027\u540d\u4e3a\u7ec4\u4ef6\u540d\uff0c\u5c5e\u6027\u503c\u4e3a\u7ec4\u4ef6\u914d\u7f6e\u5bf9\u8c61\n        MyComp: myComp,\n    },\n    template: `&lt;div&gt;\n            &lt;my-comp&gt;&lt;\/my-comp&gt;\n        &lt;\/div&gt;`\n})\n<\/code><\/pre>\n<h3>\u5e94\u7528\u7ec4\u4ef6<\/h3>\n<p>\u5c06\u7ec4\u4ef6\u540d\u5f53\u4f5cHTML\u5143\u7d20\u540d\u4f7f\u7528\u5373\u53ef<\/p>\n<ol>\n<li>\u7ec4\u4ef6\u5fc5\u987b\u6709\u7ed3\u675f<br \/>\n\u53ef\u4ee5\u81ea\u7ed3\u675f\uff0c\u4e5f\u53ef\u4f7f\u7528\u7ed3\u675f\u6807\u8bb0<\/li>\n<li>\u7ec4\u4ef6\u7684\u547d\u540d<br \/>\n\u53ef\u4ee5\u4f7f\u7528kebab-case\u77ed\u6a2a\u7ebf\u547d\u540d\u6cd5\uff0c\u4e5f\u53ef\u4f7f\u7528PascalCase\u5927\u9a7c\u5cf0\u547d\u540d\u6cd5<br \/>\n\u82e5\u4f7f\u7528\u5927\u9a7c\u5cf0\u547d\u540d\u6cd5\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4f7f\u7528\u4e24\u79cd\u7ec4\u4ef6\u540d<\/li>\n<\/ol>\n<blockquote>\n<p>\u5b9e\u9645\u4e0a\uff0c\u4f7f\u7528\u5c0f\u9a7c\u5cf0\u547d\u540d\u6cd5camelCase\u4e5f\u53ef\u4ee5\u8bc6\u522b\uff0c\u4e0d\u8fc7\u4e0d\u7b26\u5408\u5b98\u65b9\u8981\u6c42\u7684\u89c4\u8303<\/p>\n<\/blockquote>\n<h2>\u7ec4\u4ef6\u6811<\/h2>\n<p>\u4e00\u4e2a\u7ec4\u4ef6\u521b\u5efa\u597d\u540e\uff0c\u53ef\u80fd\u88ab\u591a\u6b21\u4f7f\u7528\uff0c\u4fbf\u4f1a\u5f62\u6210\u7ec4\u4ef6\u6811<\/p>\n<h2>\u5411\u7ec4\u4ef6\u4f20\u9012\u6570\u636e<\/h2>\n<pre><code class=\"language-js\">let ChildComp = {\n    props: [&quot;msg&quot;],\n    template: `\n    &lt;h2&gt;{{ msg || 'No props passed yet' }}&lt;\/h2&gt;\n    `\n}\nlet vm = new Vue({\n    el: ...\n    components: {\n        ChildComp,\n    }\n    template: `&lt;div&gt;\n            &lt;child-comp msg=&quot;Hello child&quot; \/&gt;\n        &lt;\/div&gt;`\n})\n<\/code><\/pre>\n<blockquote>\n<p>:msg \u548c msg<br \/>\n\u82e5\u4f7f\u7528 :msg \u5373 v-bind:msg \u65f6\uff0c\u5f15\u53f7\u5185\u90e8\u88ab\u5f53\u4f5cjs\u4ee3\u7801\u4f20\u9012<br \/>\n\u4e0d\u4f7f\u7528 v-bind \u5219\u5f53\u4f5c\u5b57\u7b26\u4e32\u4f20\u9012<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong>\u5355\u5411\u6570\u636e\u6d41<\/strong><br \/>\n<strong>\u5728\u7ec4\u4ef6\u4e2d\uff0c\u5c5e\u6027\u53ea\u8bfb\uff0c\u7edd\u4e0d\u53ef\u4ee5\u66f4\u6539<\/strong><\/p>\n<\/blockquote>\n<h2>\u5de5\u7a0b\u5316<\/h2>\n<pre><code class=\"language-plaintext\">TODOList\n\u251c\u2500 index.html\n\u251c\u2500 lib\n\u2502  \u2514\u2500 vue.js\n\u2514\u2500 src\n   \u251c\u2500 App.js\n   \u251c\u2500 components\n   \u2502  \u2514\u2500 TodoLists.js\n   \u2514\u2500 main.js\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduce \u4f7f\u7528 \u4f7f\u7528 vue \u7684\u4e24\u79cd\u65b9\u5f0f\uff1a \u5f15\u5165 vue \u7684 js \u6587\u4ef6 \u811a\u624b\u67b6 \u5b98\u65b9\u811a\u624b\u67b6 vue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-789","post","type-post","status-publish","format-standard","hentry","category-front-end"],"_links":{"self":[{"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/posts\/789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/levin.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=789"}],"version-history":[{"count":2,"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/posts\/789\/revisions"}],"predecessor-version":[{"id":847,"href":"https:\/\/levin.ink\/index.php?rest_route=\/wp\/v2\/posts\/789\/revisions\/847"}],"wp:attachment":[{"href":"https:\/\/levin.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/levin.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/levin.ink\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}