{"id":731,"date":"2024-01-12T09:56:29","date_gmt":"2024-01-12T01:56:29","guid":{"rendered":"http:\/\/ericw.top\/?p=731"},"modified":"2024-01-12T11:20:36","modified_gmt":"2024-01-12T03:20:36","slug":"%e6%8f%92%e6%a7%bd","status":"publish","type":"post","link":"http:\/\/ericw.top\/?p=731","title":{"rendered":"\u63d2\u69fd"},"content":{"rendered":"\n<p><strong>\u4f5c\u7528\uff1a<\/strong>\u8ba9\u7ec4\u4ef6\u5185\u90e8\u7684\u4e00\u4e9b <strong>\u7ed3\u6784 <\/strong>\u652f\u6301 <strong>\u81ea\u5b9a\u4e49<\/strong><\/p>\n\n\n\n<p><strong>\u9700\u6c42:<\/strong>\uff1a\u5c06\u9700\u8981\u591a\u6b21\u663e\u793a\u7684\u5bf9\u8bdd\u6846, \u5c01\u88c5\u6210\u4e00\u4e2a\u7ec4\u4ef6<\/p>\n\n\n\n<p><em><sub><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u95ee\u9898\uff1a\u7ec4\u4ef6\u7684\u5185\u5bb9\u90e8\u5206\uff0c<strong>\u4e0d\u5e0c\u671b\u5199\u6b7b<\/strong>\uff0c\u5e0c\u671b\u80fd\u4f7f\u7528\u7684\u65f6\u5019\u81ea\u5b9a\u4e49\u3002\u600e\u4e48\u529e\uff1f<\/mark><\/sub><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"265\" src=\"http:\/\/ericw.top\/wp-content\/uploads\/2024\/01\/image-47-1024x265.png\" alt=\"\" class=\"wp-image-732\" srcset=\"http:\/\/ericw.top\/wp-content\/uploads\/2024\/01\/image-47-1024x265.png 1024w, http:\/\/ericw.top\/wp-content\/uploads\/2024\/01\/image-47-300x78.png 300w, http:\/\/ericw.top\/wp-content\/uploads\/2024\/01\/image-47-768x199.png 768w, http:\/\/ericw.top\/wp-content\/uploads\/2024\/01\/image-47.png 1109w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><br>1.\u7ec4\u4ef6\u5185\u9700\u8981\u7684\u7ed3\u6784\u90e8\u5206\uff0c\u6539\u7528<code class=\"prettyprint\" >&lt;slot&gt;&lt;\/slot&gt;<\/code>\u5360\u4f4d<br>2.\u4f7f\u7528\u7ec4\u4ef6\u65f6\uff0c<code class=\"prettyprint\" >&lt;MyDialog&gt;&lt;\/MyDialog&gt;<\/code>\u6807\u7b7e\u5185\u90e8\uff0c\u4f20\u5165\u7ed3\u6784\u66ff\u6362<code class=\"prettyprint\" >slot<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-0\">\u540e\u5907\u5185\u5bb9<\/h2>\n\n\n\n<p>\u901a\u8fc7\u63d2\u69fd\u53ef\u4ee5\u4f20\u5185\u5bb9\u7684\u5b9a\u5236\uff0c\u4f20\u4ec0\u4e48\u663e\u793a\u4ec0\u4e48\uff0c\u4e0d\u4f20\u7684\u8bdd\uff0c\u5219\u7a7a\u767d<br>\u90a3\u6211\u4eec\u5c31\u9700\u8981\u7ed9\u4ed6\u8bbe\u7f6e<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u9ed8\u8ba4\u5185\u5bb9<\/mark><\/strong><\/p>\n\n\n\n<p><strong>\u540e\u5907\u5185\u5bb9\u8bed\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<p>\u5728&lt;slot>\u6807\u7b7e\u5185\uff0c\u6dfb\u52a0\u5185\u5bb9\uff0c\u4f5c\u4e3a\u9ed8\u8ba4\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;slot&gt;\u6211\u662f\u9ed8\u8ba4\u5185\u5bb9&lt;\/slot&gt;<\/code><\/pre>\n\n\n\n<ul>\n<li>\u5728\u5916\u90e8\u4f7f\u7528\u7ec4\u4ef6\u65f6\uff0c\u4e0d\u4f20\u5185\u5bb9\uff0c\u5219\u663e\u793aslot\u7684\u9ed8\u8ba4\u5185\u5bb9<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;MyDialog&gt;&lt;\/MyDialog&gt;<\/code><\/pre>\n\n\n\n<ul>\n<li>\u5728\u5916\u90e8\u7ec4\u4ef6\uff0c\u4f20\u4e1c\u897f\u65f6\uff0c\u5219solt\u6574\u4f53\u88ab\u66ff\u6362<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;MyDialog&gt;\u4f20\u5165\u66ff\u6362\u5185\u5bb9&lt;\/MyDialog&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-1\">\u5177\u540d\u63d2\u69fd<\/h2>\n\n\n\n<p>\u4e00\u4e2a\u7ec4\u4ef6\u5185\u6709\u591a\u5904\u7ed3\u6784\uff0c\u9700\u8981\u5916\u90e8\u4f20\u5165\u6807\u7b7e\uff0c\u8fdb\u884c\u5b9a\u5236<\/p>\n\n\n\n<p><strong>\u5177\u540d\u63d2\u69fd\u8bed\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<p>1\u3001\u591a\u4e2aslot\u4f7f\u7528<code class=\"prettyprint\" >name<\/code>\u5c5e\u6027\u533a\u5206\u540d\u5b57<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;div class=&quot;dialog-header&quot;&gt;\r\n  &lt;slot name=&quot;head&quot;&gt;&lt;\/slot&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=&quot;dialog-content&quot;&gt;\r\n  &lt;slot name=&quot;content&quot;&gt;&lt;\/slot&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=&quot;dialog-footer&quot;&gt;\r\n  &lt;slot name=&quot;footer&quot;&gt;&lt;\/slot&gt;\r\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p>2\u3001template\u914d\u5408<code class=\"prettyprint\" >v-slot:\u540d\u5b57<\/code> \u6765\u533a\u5206\u5bf9\u5e94\u6807\u7b7e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;MyDialog&gt;\r\n  &lt;template v-slot:head&gt;\r\n    \u5927\u6807\u9898\r\n  &lt;\/template&gt;\r\n  &lt;template v-slot:content&gt;\r\n    \u5185\u5bb9\u6587\u672c\r\n  &lt;\/template&gt;\r\n  &lt;template v-slot:footer&gt;\r\n    &lt;button&gt;\u6309\u94ae&lt;\/button&gt;\r\n  &lt;\/template&gt;\r\n&lt;\/MyDialog&gt;<\/code><\/pre>\n\n\n\n<p><strong>\u7b80\u5316\u5199\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<p><code class=\"prettyprint\" >v-slot:\u63d2\u69fd\u540d<\/code> \u53ef\u4ee5\u7b80\u5316\u6210 <code class=\"prettyprint\" >#\u63d2\u69fd\u540d<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;MyDialog&gt;\r\n  &lt;template #head&gt;\r\n    \u5927\u6807\u9898\r\n  &lt;\/template&gt;\r\r\n&lt;\/MyDialog&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-2\">\u4f5c\u7528\u57df\u63d2\u69fd<\/h2>\n\n\n\n<p><strong>\u4f5c\u7528\u57df\u63d2\u69fd: <\/strong>\u5b9a\u4e49 <code class=\"prettyprint\" >slot <\/code>\u63d2\u69fd\u7684\u540c\u65f6, \u662f\u53ef\u4ee5<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u4f20\u503c<\/mark>\u7684\u3002\u7ed9 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u63d2\u69fd<\/mark> \u4e0a\u53ef\u4ee5 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u7ed1\u5b9a\u6570\u636e<\/mark>\uff0c\u5c06\u6765 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u4f7f\u7528\u7ec4\u4ef6\u65f6\u53ef\u4ee5\u7528<\/mark>\u3002<\/p>\n\n\n\n<p><strong>\u573a\u666f\uff1a\u5c01\u88c5\u8868\u683c\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<p>1. \u7236\u4f20\u5b50\uff0c\u52a8\u6001\u6e32\u67d3\u8868\u683c\u5185\u5bb9<\/p>\n\n\n\n<p>2. \u5229\u7528\u9ed8\u8ba4\u63d2\u69fd\uff0c\u5b9a\u5236\u64cd\u4f5c\u5217<\/p>\n\n\n\n<p>3. \u5220\u9664\u6216\u67e5\u770b\u90fd\u9700\u8981\u7528\u5230 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">\u5f53\u524d\u9879\u7684 id<\/mark>\uff0c\u5c5e\u4e8e <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">\u7ec4\u4ef6\u5185\u90e8\u7684\u6570\u636e<\/mark><\/p>\n\n\n\n<p>\u901a\u8fc7 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u4f5c\u7528\u57df\u63d2\u69fd<\/mark> \u4f20\u503c\u7ed1\u5b9a\uff0c\u8fdb\u800c\u4f7f\u7528<\/p>\n\n\n\n<p><strong>\u57fa\u672c\u4f7f\u7528\u6b65\u9aa4\uff1a<\/strong><\/p>\n\n\n\n<p>1\u3001\u7ed9 <code class=\"prettyprint\" >slot <\/code>\u6807\u7b7e, \u4ee5 \u6dfb\u52a0\u5c5e\u6027\u7684\u65b9\u5f0f\u4f20\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;slot :id=&quot;item.id&quot; msg=&quot;\u6d4b\u8bd5\u6587\u672c&quot;&gt;&lt;\/slot&gt;<\/code><\/pre>\n\n\n\n<p>2\u3001\u6240\u6709\u6dfb\u52a0\u7684\u5c5e\u6027, \u90fd\u4f1a\u88ab\u6536\u96c6\u5230\u4e00\u4e2a\u5bf9\u8c61\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >{ id: 3, msg: &#039;\u6d4b\u8bd5\u6587\u672c&#039; }<\/code><\/pre>\n\n\n\n<p>3\u3001\u5728template\u4e2d, \u901a\u8fc7 ` <code class=\"prettyprint\" >#\u63d2\u69fd\u540d= &quot;obj&quot;<\/code> ` \u63a5\u6536\uff0c\u9ed8\u8ba4\u63d2\u69fd\u540d\u4e3a <code class=\"prettyprint\" >default<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >&lt;MyTable :list=&quot;list&quot;&gt;\r\n  &lt;template #default=&quot;obj&quot;&gt;\r\n    &lt;button @click=&quot;del(obj.id)&quot;&gt;\u5220\u9664&lt;\/button&gt;\r\n  &lt;\/template&gt;\r\n&lt;\/MyTable&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u7528\uff1a\u8ba9\u7ec4\u4ef6\u5185\u90e8\u7684\u4e00\u4e9b \u7ed3\u6784 \u652f\u6301 \u81ea\u5b9a\u4e49 \u9700\u6c42:\uff1a\u5c06\u9700\u8981\u591a\u6b21\u663e\u793a\u7684\u5bf9\u8bdd\u6846, \u5c01\u88c5\u6210\u4e00\u4e2a\u7ec4\u4ef6 \u95ee\u9898\uff1a\u7ec4\u4ef6\u7684\u5185\u5bb9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":734,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,5],"tags":[],"_links":{"self":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/731"}],"collection":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=731"}],"version-history":[{"count":1,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions"}],"predecessor-version":[{"id":735,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions\/735"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/media\/734"}],"wp:attachment":[{"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=731"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}