Skip to content

Commit 5c798ba

Browse files
various-hooksLJN26
andauthored
docs: slots (#386)
* feat(md): add <slot/> to jsx md Co-authored-by: GetKnowledge <[email protected]>
1 parent 0e4a660 commit 5c798ba

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

packages/babel-plugin-jsx/README-zh_CN.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,17 @@ const App = {
234234
> 注意: 在 `jsx` 中,应该使用 **`v-slots`** 代替 _`v-slot`_
235235
236236
```jsx
237+
const A = (props, { slots }) => (
238+
<>
239+
<h1>{ slots.default ? slots.default() : 'foo' }</h1>
240+
<h2>{ slots.bar?.() }</h2>
241+
</>
242+
);
243+
237244
const App = {
238245
setup() {
239246
const slots = {
240-
foo: () => <span>B</span>,
247+
bar: () => <span>B</span>,
241248
};
242249
return () => (
243250
<A v-slots={slots}>
@@ -253,7 +260,7 @@ const App = {
253260
setup() {
254261
const slots = {
255262
default: () => <div>A</div>,
256-
foo: () => <span>B</span>,
263+
bar: () => <span>B</span>,
257264
};
258265
return () => <A v-slots={slots} />;
259266
},
@@ -267,7 +274,7 @@ const App = {
267274
<A>
268275
{{
269276
default: () => <div>A</div>,
270-
foo: () => <span>B</span>,
277+
bar: () => <span>B</span>,
271278
}}
272279
</A>
273280
<B>{() => "foo"}</B>

packages/babel-plugin-jsx/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,17 @@ const App = {
238238
> Note: In `jsx`, _`v-slot`_ should be replace with **`v-slots`**
239239
240240
```jsx
241+
const A = (props, { slots }) => (
242+
<>
243+
<h1>{ slots.default ? slots.default() : 'foo' }</h1>
244+
<h2>{ slots.bar?.() }</h2>
245+
</>
246+
);
247+
241248
const App = {
242249
setup() {
243250
const slots = {
244-
foo: () => <span>B</span>,
251+
bar: () => <span>B</span>,
245252
};
246253
return () => (
247254
<A v-slots={slots}>
@@ -257,7 +264,7 @@ const App = {
257264
setup() {
258265
const slots = {
259266
default: () => <div>A</div>,
260-
foo: () => <span>B</span>,
267+
bar: () => <span>B</span>,
261268
};
262269
return () => <A v-slots={slots} />;
263270
},
@@ -271,7 +278,7 @@ const App = {
271278
<A>
272279
{{
273280
default: () => <div>A</div>,
274-
foo: () => <span>B</span>,
281+
bar: () => <span>B</span>,
275282
}}
276283
</A>
277284
<B>{() => "foo"}</B>

0 commit comments

Comments
 (0)