{"id":8320,"date":"2023-11-28T20:24:48","date_gmt":"2023-11-28T12:24:48","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8320"},"modified":"2023-12-02T22:31:21","modified_gmt":"2023-12-02T14:31:21","slug":"vue-zhong-qing-shuo-xia-feng-zhuangvue-zu-jian-de-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/vue-zhong-qing-shuo-xia-feng-zhuangvue-zu-jian-de-2\/","title":{"rendered":"Vue \u4e2d\u8bf7\u8bf4\u4e0b\u5c01\u88c5 vue \u7ec4\u4ef6\u7684\u8fc7\u7a0b\uff1f"},"content":{"rendered":"<p>\u5c01\u88c5 Vue \u7ec4\u4ef6\u662f\u5c06\u529f\u80fd\u548c UI \u62bd\u8c61\u6210\u53ef\u91cd\u7528\u7684\u6a21\u5757\uff0c\u4f7f\u5f97\u5728\u5e94\u7528\u4e2d\u53ef\u4ee5\u591a\u6b21\u4f7f\u7528\u3002\u4e0b\u9762\u662f\u5c01\u88c5 Vue \u7ec4\u4ef6\u7684\u4e00\u822c\u6b65\u9aa4\uff1a<\/p>\n<h3><a id=\"1%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>1. \u5b9a\u4e49\u7ec4\u4ef6\uff1a<\/h3>\n<p>\u521b\u5efa\u4e00\u4e2a <code>.vue<\/code> \u6587\u4ef6\uff0c\u5305\u542b\u6a21\u677f\u3001\u811a\u672c\u548c\u6837\u5f0f\uff0c\u5b9a\u4e49\u7ec4\u4ef6\u7684\u7ed3\u6784\u548c\u529f\u80fd\u3002<\/p>\n<h3><a id=\"2%E7%BC%96%E5%86%99%E7%BB%84%E4%BB%B6%E6%A8%A1%E6%9D%BF%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>2. \u7f16\u5199\u7ec4\u4ef6\u6a21\u677f\uff1a<\/h3>\n<p>\u5728 <code>.vue<\/code> \u6587\u4ef6\u4e2d\u7f16\u5199\u7ec4\u4ef6\u7684\u6a21\u677f\u90e8\u5206\uff0c\u5b9a\u4e49\u7ec4\u4ef6\u7684\u7ed3\u6784\u548c\u5e03\u5c40\u3002<\/p>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div class=&quot;custom-component&quot;&gt;\n    &lt;!-- \u7ec4\u4ef6\u6a21\u677f\u5185\u5bb9 --&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n<\/code><\/pre>\n<h3><a id=\"3%E5%AE%9E%E7%8E%B0%E7%BB%84%E4%BB%B6%E9%80%BB%E8%BE%91%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>3. \u5b9e\u73b0\u7ec4\u4ef6\u903b\u8f91\uff1a<\/h3>\n<p>\u7f16\u5199\u7ec4\u4ef6\u7684\u811a\u672c\u90e8\u5206\uff0c\u5b9e\u73b0\u7ec4\u4ef6\u7684\u903b\u8f91\u3001\u65b9\u6cd5\u548c\u6570\u636e\u5904\u7406\u7b49\u529f\u80fd\u3002<\/p>\n<pre><code class=\"language-vue\">&lt;script&gt;\nexport default {\n  data() {\n    return {\n      \/\/ \u7ec4\u4ef6\u7684\u6570\u636e\n    };\n  },\n  methods: {\n    \/\/ \u7ec4\u4ef6\u7684\u65b9\u6cd5\n  },\n  \/\/ \u5176\u4ed6\u7ec4\u4ef6\u9009\u9879\n};\n&lt;\/script&gt;\n<\/code><\/pre>\n<h3><a id=\"4%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E6%A0%B7%E5%BC%8F%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>4. \u5b9a\u4e49\u7ec4\u4ef6\u6837\u5f0f\uff1a<\/h3>\n<p>\u5728 <code>.vue<\/code> \u6587\u4ef6\u4e2d\u7f16\u5199\u7ec4\u4ef6\u7684\u6837\u5f0f\uff0c\u901a\u8fc7 CSS \u6216\u9884\u5904\u7406\u5668\u5b9a\u4e49\u7ec4\u4ef6\u7684\u5916\u89c2\u6837\u5f0f\u3002<\/p>\n<pre><code class=\"language-vue\">&lt;style&gt;\n.custom-component {\n  \/* \u7ec4\u4ef6\u6837\u5f0f *\/\n}\n&lt;\/style&gt;\n<\/code><\/pre>\n<h3><a id=\"5%E6%B3%A8%E5%86%8C%E7%BB%84%E4%BB%B6%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>5. \u6ce8\u518c\u7ec4\u4ef6\uff1a<\/h3>\n<p>\u5728\u9700\u8981\u4f7f\u7528\u7ec4\u4ef6\u7684\u5730\u65b9\uff0c\u901a\u8fc7\u5168\u5c40\u6216\u5c40\u90e8\u65b9\u5f0f\u6ce8\u518c\u7ec4\u4ef6\uff0c\u4f7f\u5176\u53ef\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u3002<\/p>\n<ul>\n<li><strong>\u5168\u5c40\u6ce8\u518c\uff1a<\/strong> \u5728\u5165\u53e3\u6587\u4ef6\u6216\u5176\u4ed6\u9002\u5f53\u4f4d\u7f6e\u4f7f\u7528 <code>Vue.component<\/code> \u65b9\u6cd5\u5168\u5c40\u6ce8\u518c\u7ec4\u4ef6\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">import CustomComponent from '@\/components\/CustomComponent.vue';\n\nVue.component('custom-component', CustomComponent);\n<\/code><\/pre>\n<ul>\n<li><strong>\u5c40\u90e8\u6ce8\u518c\uff1a<\/strong> \u5728\u9700\u8981\u4f7f\u7528\u7ec4\u4ef6\u7684\u7ec4\u4ef6\u4e2d\u901a\u8fc7 <code>components<\/code> \u9009\u9879\u5c40\u90e8\u6ce8\u518c\u7ec4\u4ef6\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">import CustomComponent from '@\/components\/CustomComponent.vue';\n\nexport default {\n  components: {\n    CustomComponent,\n  },\n  \/\/ ...\n};\n<\/code><\/pre>\n<h3><a id=\"6%E4%BD%BF%E7%94%A8%E7%BB%84%E4%BB%B6%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>6. \u4f7f\u7528\u7ec4\u4ef6\uff1a<\/h3>\n<p>\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u7ec4\u4ef6\u6807\u7b7e\u6765\u4f7f\u7528\u5c01\u88c5\u597d\u7684\u7ec4\u4ef6\uff0c\u4f20\u9012 props\u3001\u8c03\u7528\u65b9\u6cd5\u7b49\u3002<\/p>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div&gt;\n    &lt;custom-component :propName=&quot;data&quot;&gt;&lt;\/custom-component&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n<\/code><\/pre>\n<h3><a id=\"7%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>7. \u53c2\u6570\u4f20\u9012\uff1a<\/h3>\n<p>\u901a\u8fc7\u7ec4\u4ef6\u7684 props \u5c5e\u6027\u4f20\u9012\u6570\u636e\u7ed9\u5b50\u7ec4\u4ef6\uff0c\u5728\u5b50\u7ec4\u4ef6\u4e2d\u63a5\u6536\u5e76\u5904\u7406\u3002<\/p>\n<h3><a id=\"8%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%B8%BB%E9%A2%98%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>8. \u6837\u5f0f\u548c\u4e3b\u9898\uff1a<\/h3>\n<p>\u4e3a\u7ec4\u4ef6\u63d0\u4f9b\u6837\u5f0f\u548c\u4e3b\u9898\uff0c\u5141\u8bb8\u7528\u6237\u6839\u636e\u9700\u8981\u81ea\u5b9a\u4e49\u5916\u89c2\u548c\u884c\u4e3a\u3002<\/p>\n<h3><a id=\"9%E6%B5%8B%E8%AF%95%E5%92%8C%E6%96%87%E6%A1%A3%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>9. \u6d4b\u8bd5\u548c\u6587\u6863\uff1a<\/h3>\n<p>\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u6765\u786e\u4fdd\u7ec4\u4ef6\u7684\u529f\u80fd\u548c\u884c\u4e3a\u7b26\u5408\u9884\u671f\uff0c\u540c\u65f6\u7f16\u5199\u6587\u6863\u6765\u63cf\u8ff0\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u53c2\u6570\u3002<\/p>\n<p>\u8fd9\u4e9b\u6b65\u9aa4\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9879\u76ee\u9700\u6c42\u548c\u7ec4\u4ef6\u590d\u6742\u5ea6\u8fdb\u884c\u8c03\u6574\u548c\u8865\u5145\uff0c\u4f46\u662f\u57fa\u672c\u7684\u6d41\u7a0b\u662f\u5b9a\u4e49\u3001\u7f16\u5199\u3001\u6ce8\u518c\u548c\u4f7f\u7528\u7ec4\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c01\u88c5 Vue \u7ec4\u4ef6\u662f\u5c06\u529f\u80fd\u548c UI \u62bd\u8c61\u6210\u53ef\u91cd\u7528\u7684\u6a21\u5757\uff0c\u4f7f\u5f97\u5728\u5e94\u7528\u4e2d\u53ef\u4ee5\u591a\u6b21\u4f7f\u7528\u3002\u4e0b\u9762\u662f\u5c01\u88c5 Vue \u7ec4\u4ef6\u7684\u4e00 [&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-8320","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8320","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=8320"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8320\/revisions"}],"predecessor-version":[{"id":14094,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8320\/revisions\/14094"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8320"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}