From 3a8e56c2aaf9963f39aea029365431b7ec4a47e9 Mon Sep 17 00:00:00 2001 From: wxsm Date: Tue, 16 Apr 2024 10:14:04 +0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ayaka <26200808+KiritaniAyaka@users.noreply.github.com> --- src/guide/components/slots.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/guide/components/slots.md b/src/guide/components/slots.md index 58c60c623..32fdfd90f 100644 --- a/src/guide/components/slots.md +++ b/src/guide/components/slots.md @@ -294,14 +294,14 @@ function BaseLayout(slots) { } ``` -## Conditional Slots {#conditional-slots} +## 条件插槽 {#conditional-slots} -Sometimes you want to render something based on whether or not a slot is present. +有时你需要根据插槽是否存在来渲染某些内容。 -You can use the [$slots](/api/component-instance.html#slots) property in combination with a [v-if](/guide/essentials/conditional.html#v-if) to achieve this. +你可以结合使用 [$slots](/api/component-instance.html#slots) 属性与 [v-if](/guide/essentials/conditional.html#v-if) 来实现。 -In the example below we define a Card component with two conditional slots: `header` and `footer`. -When the header / footer is present we want wrap them to provide additional styling: +在下面的示例中,我们定义了一个卡片组件,它拥有两个条件插槽:`header` 和 `footer`。 +当 header 或 footer 存在时,我们希望包装它们以提供额外的样式: ```vue-html ``` -[Try it in the Playground](https://play.vuejs.org/#eNqFVD1v2zAQ/SsEWyBLIjVoJlcN0AYZ2qEt2oxaaOkkMaZIgqRcGYH/e4+kqFi26wAejvfevfu0XugXrbPtAHRFC1sZrh2x4AZ9X0rea2UceWCmJo1RPbnKcv/w9KtSFnnkIxMfDnotmAN8EVJ4WrDQTgh51wGrwUx+RLrb+6eOW4I/1wGJcJGjewrND1RP1Gpo2CB8+klOL9QqJR1IV+S+lbfVGqXcYW3QL9QiXOToPqPmn1PLCz+9ps5iIQ1vs2erJA75xbNLWqlecwHmp3ZcSVvSFQmIx5gQ6u/34HNmgOvkrzqoNmf8z3b0vpL+MmDBbKGkM+aYacFF+PHPDxjRnsFe1YNA9gXwN1glBl9jpH0dZI1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duU1O+UM/cB35J8XQeLrT+Wu7H7C7ElXKPU0xn5690Ofeab0klmLWfcUDIKmlakEe2N7xB4L0VytksHlhJFwE3yfu6e88mkvWAlDkmnxePwpN9kGkhOd3eieYbGstq48kdV5u856udY04zJevob1BYtxNxlplPkHaxVgb7XpFbPRI8AV6TtWDV5lNENatr3PaKfAgO3NIsMM1z1sGg1ig8G5yKUKhoN7u1GOBY6U6Pp1rTIJPYZXJs/v+JBW871xq2u5g6fNjCTOj+H/sTpqs=) ## 动态插槽名 {#dynamic-slot-names}