{"id":53030,"date":"2024-12-03T11:25:39","date_gmt":"2024-12-03T03:25:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53030\/"},"modified":"2024-12-03T11:25:39","modified_gmt":"2024-12-03T03:25:39","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-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53030\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f <\/h1>\n<p>\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u8981\u52aa\u529b\uff0c\u4f46\u662f\u4e0d\u8981\u6025\uff01\u4eca\u5929\u7684\u8fd9\u7bc7\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f \u300b<\/span>\u5c06\u4f1a\u4ecb\u7ecd\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u60f3\u6df1\u5165\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u53ef\u4ee5\u5173\u6ce8\u6211\uff01\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u6587\u7ae0\u7684\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u80fd\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/1732539821674475ad58ae4.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>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<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>\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>\u4eca\u5929\u5173\u4e8e\u300a\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f \u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u7c73\u4e91\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u5b9e\u73b0\u7236\u5143\u7d20\u5185\u5b50\u5143\u7d20\u4e24\u884c\u6392\u5217\uff0c\u8d85\u51fa\u90e8\u5206\u9690\u85cf\u5e76\u663e\u793a\u7701\u7565\u53f7\u6309\u94ae\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f \u5b66\u4e60\u6587\u7ae0\u8981\u52aa\u529b\uff0c\u4f46\u662f\u4e0d\u8981\u6025\uff01\u4eca\u5929\u7684\u8fd9\u7bc7\u6587\u7ae0\u300a\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd \u5185\u5bb9\u6ca1\u663e\u793a\uff1f \u300b\u5c06\u4f1a\u4ecb\u7ecd\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u60f3\u6df1\u5165\u5b66\u4e60\u6587\u7ae0\uff0c\u53ef\u4ee5\u5173\u6ce8\u6211\uff01\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u6587\u7ae0\u7684\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u80fd\u6709\u6240\u5e2e\u52a9\uff01 \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; 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 } }) \u5728 Vue.config.global.components \u5bf9\u8c61\u4e2d\u5168\u5c40\u6ce8\u518c\u7ec4\u4ef6\uff1a Vue.config.global.components = { ExampleComponent } \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 \u4eca\u5929\u5173\u4e8e\u300a\u4e3a\u4ec0\u4e48\u6211\u7684 \u5177\u540d\u63d2\u69fd [&hellip;]<\/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-53030","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53030","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=53030"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53030\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}