{"id":8506,"date":"2023-11-28T20:29:56","date_gmt":"2023-11-28T12:29:56","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8506"},"modified":"2023-12-02T22:57:22","modified_gmt":"2023-12-02T14:57:22","slug":"vue-zhong-yin-jin-zu-jian-de-bu-zhou","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/vue-zhong-yin-jin-zu-jian-de-bu-zhou\/","title":{"rendered":"Vue \u4e2d\u5f15\u8fdb\u7ec4\u4ef6\u7684\u6b65\u9aa4\uff1f"},"content":{"rendered":"<p>\u5728 Vue \u4e2d\u5f15\u5165\u7ec4\u4ef6\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<h3><a id=\"1%E5%88%9B%E5%BB%BA%E7%BB%84%E4%BB%B6%E6%96%87%E4%BB%B6\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>1. \u521b\u5efa\u7ec4\u4ef6\u6587\u4ef6<\/h3>\n<p>\u521b\u5efa\u4e00\u4e2a.vue\u6587\u4ef6\uff0c\u5305\u542b\u7ec4\u4ef6\u7684\u6a21\u677f\u3001\u6837\u5f0f\u548c\u903b\u8f91\u3002\u6bd4\u5982\u4e00\u4e2a\u540d\u4e3a <code>MyComponent.vue<\/code> \u7684\u7ec4\u4ef6\u6587\u4ef6\u53ef\u80fd\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div&gt;\n    &lt;h1&gt;{{ title }}&lt;\/h1&gt;\n    &lt;p&gt;{{ description }}&lt;\/p&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  data() {\n    return {\n      title: 'Hello',\n      description: 'This is a Vue component!',\n    };\n  },\n};\n&lt;\/script&gt;\n\n&lt;style scoped&gt;\n\/* \u7ec4\u4ef6\u6837\u5f0f *\/\nh1 {\n  color: blue;\n}\np {\n  font-size: 16px;\n}\n&lt;\/style&gt;\n<\/code><\/pre>\n<h3><a id=\"2%E5%BC%95%E5%85%A5%E7%BB%84%E4%BB%B6\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>2. \u5f15\u5165\u7ec4\u4ef6<\/h3>\n<p>\u5728\u9700\u8981\u4f7f\u7528\u8be5\u7ec4\u4ef6\u7684\u5730\u65b9\uff0c\u901a\u8fc7 <code>import<\/code> \u5f15\u5165\u7ec4\u4ef6\u6587\u4ef6\u3002<\/p>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div&gt;\n    &lt;MyComponent&gt;&lt;\/MyComponent&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nimport MyComponent from '.\/MyComponent.vue';\n\nexport default {\n  components: {\n    MyComponent,\n  },\n};\n&lt;\/script&gt;\n<\/code><\/pre>\n<h3><a id=\"3%E6%B3%A8%E5%86%8C%E7%BB%84%E4%BB%B6\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>3. \u6ce8\u518c\u7ec4\u4ef6<\/h3>\n<p>\u5728\u7236\u7ec4\u4ef6\u4e2d\uff0c\u901a\u8fc7 <code>components<\/code> \u5c5e\u6027\u5c06\u5f15\u5165\u7684\u7ec4\u4ef6\u6ce8\u518c\u4e3a\u81ea\u5df1\u7684\u5b50\u7ec4\u4ef6\uff0c\u8fd9\u6837\u7236\u7ec4\u4ef6\u5c31\u53ef\u4ee5\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u8be5\u5b50\u7ec4\u4ef6\u4e86\u3002<\/p>\n<h3><a id=\"4%E4%BD%BF%E7%94%A8%E7%BB%84%E4%BB%B6\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>4. \u4f7f\u7528\u7ec4\u4ef6<\/h3>\n<p>\u5728\u7236\u7ec4\u4ef6\u7684\u6a21\u677f\u4e2d\uff0c\u4f7f\u7528\u6ce8\u518c\u8fc7\u7684\u7ec4\u4ef6\u6807\u7b7e\u6765\u5f15\u5165\u8be5\u7ec4\u4ef6\u3002\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c<code>&lt;MyComponent&gt;&lt;\/MyComponent&gt;<\/code> \u5c31\u662f\u4f7f\u7528 <code>MyComponent<\/code> \u7ec4\u4ef6\u7684\u65b9\u5f0f\u3002<\/p>\n<h3><a id=\"5%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>5. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>\u786e\u4fdd\u7ec4\u4ef6\u7684\u6587\u4ef6\u8def\u5f84\u548c\u5f15\u5165\u7684\u8def\u5f84\u6b63\u786e\uff0c\u4e14\u6587\u4ef6\u540d\u5927\u5c0f\u5199\u4e0e\u5f15\u5165\u4fdd\u6301\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u7ec4\u4ef6\u65f6\u8981\u9075\u5faa\u9a7c\u5cf0\u5f0f\u547d\u540d\u8f6c\u6362\u4e3a\u77ed\u6a2a\u7ebf\u5206\u9694\u7684\u89c4\u5219\uff0c\u6bd4\u5982\u5728 Vue \u6a21\u677f\u4e2d\u4f7f\u7528 <code>MyComponent<\/code>\uff0c\u5bf9\u5e94\u7684 HTML \u6807\u7b7e\u540d\u5e94\u8be5\u662f <code>&lt;my-component&gt;&lt;\/my-component&gt;<\/code>\u3002<\/p>\n<p>\u9075\u5faa\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f60\u5c31\u80fd\u591f\u5728 Vue \u4e2d\u6210\u529f\u5f15\u5165\u5e76\u4f7f\u7528\u81ea\u5df1\u521b\u5efa\u7684\u7ec4\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Vue \u4e2d\u5f15\u5165\u7ec4\u4ef6\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a 1. \u521b\u5efa\u7ec4\u4ef6\u6587\u4ef6 \u521b\u5efa\u4e00\u4e2a.vue\u6587\u4ef6\uff0c\u5305\u542b\u7ec4\u4ef6\u7684\u6a21\u677f\u3001\u6837\u5f0f\u548c\u903b\u8f91 [&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-8506","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8506","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=8506"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8506\/revisions"}],"predecessor-version":[{"id":14123,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8506\/revisions\/14123"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8506"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}