Skip to content

Commit

Permalink
update slot example
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Oct 27, 2021
1 parent dd285aa commit 61e4a2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion example/slotsComponent/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export default {
msg: "your name is child",
},
{
default: () => h("p", {}, "我是通过 slot 渲染出来的"),
default: ({ age }) => [
h("p", {}, "我是通过 slot 渲染出来的第一个元素 "),
h("p", {}, "我是通过 slot 渲染出来的第二个元素"),
h("p", {}, `我可以接收到 age: ${age}`),
],
}
),
]);
Expand Down
5 changes: 4 additions & 1 deletion example/slotsComponent/Child.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export default {
h("div", {}, "child"),
// renderSlot 会返回一个 vnode
// 其本质和 h 是一样的
renderSlot(this.$slots, "default"),
// 第三个参数给出数据
renderSlot(this.$slots, "default", {
age: 16,
}),
]);
},
};

0 comments on commit 61e4a2e

Please sign in to comment.