{"id":3893,"date":"2024-11-10T13:47:56","date_gmt":"2024-11-10T05:47:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3893\/"},"modified":"2024-11-10T13:47:56","modified_gmt":"2024-11-10T05:47:56","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84-%e5%85%b7%e5%90%8d%e6%8f%92%e6%a7%bd-%e5%86%85%e5%ae%b9%e6%b2%a1%e6%98%be%e7%a4%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3893\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173116098448570.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5177\u540d\u63d2\u69fd\u7684\u56f0\u60d1<\/strong><\/p>\n<p>\u5728 Vue.js \u4e2d\uff0c\u5177\u540d\u63d2\u69fd\u7684\u4f7f\u7528\u53ef\u4ee5\u4f7f\u7ec4\u4ef6\u66f4\u52a0\u7075\u6d3b\uff0c\u5141\u8bb8\u5b50\u7ec4\u4ef6\u5728\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165\u7279\u5b9a\u5185\u5bb9\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528\u5177\u540d\u63d2\u69fd\u65f6\uff0c\u6709\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u610f\u5916\u60c5\u51b5\u3002<\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u4f8b\u5982\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;div&gt;\n  &lt;example-component&gt;\n    &lt;template v-slot:some-slot&gt;\n      Customized content\n    &lt;\/template&gt;\n  &lt;\/example-component&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>expectExample \u7ec4\u4ef6\u5b9a\u4e49\u4e86\u5177\u6709\u540d\u79f0\u4e3a &#8220;some-slot&#8221; \u7684\u5177\u540d\u63d2\u69fd\uff0c\u5e76\u4e14\u793a\u4f8b\u4ee3\u7801\u4e2d\u5df2\u4e3a\u8be5\u63d2\u69fd\u63d0\u4f9b\u4e86\u5185\u5bb9\u3002\u7136\u800c\uff0c\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u5374\u672a\u663e\u793a\u8be5 slot \u7684\u5185\u5bb9\u3002<\/p>\n<p><strong>\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u4e00\u4e2a\u53ef\u80fd\u7684\u539f\u56e0\u662f\uff0cexample-component \u5df2\u6ce8\u518c\u4e3a\u4e00\u4e2a\u5168\u5c40\u7ec4\u4ef6\uff0c\u5e76\u4e14\u5728\u793a\u4f8b\u4ee3\u7801\u4e4b\u5916\u5df2\u7ecf\u67d0\u4e2a\u5730\u65b9\u4f7f\u7528\u4e86\u5b83\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u89e3\u51b3\u6b64\u95ee\u9898\u7684\u65b9\u6cd5\u662f\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u5904\u7406\u7ec4\u4ef6\u6ce8\u518c\u95ee\u9898\u3002\u53ef\u4ee5\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\u5728 Vue \u5b9e\u4f8b\u4e2d\u624b\u52a8\u6ce8\u518c\u7ec4\u4ef6\uff1a<\/li>\n<\/ol>\n<pre>new Vue({\n  components: {\n    ExampleComponent: ExampleComponent\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5728 Vue.config.global.components \u5bf9\u8c61\u4e2d\u5168\u5c40\u6ce8\u518c\u7ec4\u4ef6\uff1a<\/li>\n<\/ol>\n<pre>Vue.config.global.components = { ExampleComponent }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u4efb\u4e00\u65b9\u6cd5\u90fd\u53ef\u4ee5\u786e\u4fdd\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u6b63\u786e\u6ce8\u518c\u7ec4\u4ef6\uff0c\u4ece\u800c\u4f7f\u5177\u540d\u63d2\u69fd\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5177\u540d\u63d2\u69fd\u7684\u56f0\u60d1 \u5728 Vue.js \u4e2d\uff0c\u5177\u540d\u63d2\u69fd\u7684\u4f7f\u7528\u53ef\u4ee5\u4f7f\u7ec4\u4ef6\u66f4\u52a0\u7075\u6d3b\uff0c\u5141\u8bb8\u5b50\u7ec4\u4ef6\u5728\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165\u7279\u5b9a\u5185\u5bb9\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528\u5177\u540d\u63d2\u69fd\u65f6\uff0c\u6709\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u610f\u5916\u60c5\u51b5\u3002 \u95ee\u9898\u63cf\u8ff0 \u4f8b\u5982\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\uff1a &lt;div&gt; &lt;example-component&gt; &lt;template v-slot:some-slot&gt; Customized content &lt;\/template&gt; &lt;\/example-component&gt; &lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 expectExample \u7ec4\u4ef6\u5b9a\u4e49\u4e86\u5177\u6709\u540d\u79f0\u4e3a &#8220;some-slot&#8221; \u7684\u5177\u540d\u63d2\u69fd\uff0c\u5e76\u4e14\u793a\u4f8b\u4ee3\u7801\u4e2d\u5df2\u4e3a\u8be5\u63d2\u69fd\u63d0\u4f9b\u4e86\u5185\u5bb9\u3002\u7136\u800c\uff0c\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u5374\u672a\u663e\u793a\u8be5 slot \u7684\u5185\u5bb9\u3002 \u539f\u56e0\u5206\u6790 \u4e00\u4e2a\u53ef\u80fd\u7684\u539f\u56e0\u662f\uff0cexample-component \u5df2\u6ce8\u518c\u4e3a\u4e00\u4e2a\u5168\u5c40\u7ec4\u4ef6\uff0c\u5e76\u4e14\u5728\u793a\u4f8b\u4ee3\u7801\u4e4b\u5916\u5df2\u7ecf\u67d0\u4e2a\u5730\u65b9\u4f7f\u7528\u4e86\u5b83\u3002 \u89e3\u51b3\u65b9\u6848 \u89e3\u51b3\u6b64\u95ee\u9898\u7684\u65b9\u6cd5\u662f\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u5904\u7406\u7ec4\u4ef6\u6ce8\u518c\u95ee\u9898\u3002\u53ef\u4ee5\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\uff1a \u5728 Vue \u5b9e\u4f8b\u4e2d\u624b\u52a8\u6ce8\u518c\u7ec4\u4ef6\uff1a new Vue({ components: { ExampleComponent: ExampleComponent } }) \u767b\u5f55\u540e\u590d\u5236 \u5728 Vue.config.global.components \u5bf9\u8c61\u4e2d\u5168\u5c40\u6ce8\u518c\u7ec4\u4ef6\uff1a Vue.config.global.components = { ExampleComponent } \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u4efb\u4e00\u65b9\u6cd5\u90fd\u53ef\u4ee5\u786e\u4fdd\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u6b63\u786e\u6ce8\u518c\u7ec4\u4ef6\uff0c\u4ece\u800c\u4f7f\u5177\u540d\u63d2\u69fd\u6b63\u5e38\u5de5\u4f5c\u3002 \u4ee5\u4e0a\u5c31\u662f\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3893","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=3893"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3893\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}