Skip to content

Commit 3e0d646

Browse files
committed
chore: slot playground
1 parent a5d9945 commit 3e0d646

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

playground/src/slots.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
template,
1414
} from '@vue/vapor'
1515

16-
const t0 = template('<div class="parnet-container"></div>')
17-
1816
// <template #mySlot="{ message, changeMessage }">
1917
// <div clas="slotted">
2018
// <h1>{{ message }}</h1>
@@ -27,30 +25,31 @@ const t1 = template(
2725

2826
const Parent = defineComponent({
2927
vapor: true,
30-
31-
setup(props) {
28+
setup(_) {
3229
return (() => {
33-
const n0 = /** @type {any} */ (t0())
34-
const s0 = createSlots({
35-
mySlot: scope => {
36-
const n1 = t1()
37-
const n2 = /** @type {any} */ (children(n1, 0))
38-
const n3 = /** @type {any} */ (children(n1, 1))
39-
renderEffect(() => {
40-
setText(n2, scope.message())
41-
})
42-
on(n3, 'click', scope.changeMessage)
43-
return [n1]
44-
},
45-
// e.g. default slot
46-
// default: () => {
47-
// const n1 = t1()
48-
// return [n1]
49-
// }
50-
})
5130
/** @type {any} */
52-
const n1 = createComponent(Child, {}, s0)
53-
return [n0, n1]
31+
const n0 = createComponent(
32+
Child,
33+
{},
34+
createSlots({
35+
mySlot: ({ message, changeMessage }) => {
36+
const n1 = t1()
37+
const n2 = /** @type {any} */ (children(n1, 0))
38+
const n3 = /** @type {any} */ (children(n1, 1))
39+
renderEffect(() => {
40+
setText(n2, message())
41+
})
42+
on(n3, 'click', changeMessage)
43+
return n1
44+
},
45+
// e.g. default slot
46+
// default: () => {
47+
// const n1 = t1()
48+
// return n1
49+
// }
50+
}),
51+
)
52+
return n0
5453
})()
5554
},
5655
})

0 commit comments

Comments
 (0)