Skip to content

Commit

Permalink
demo: update slots demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Feb 22, 2021
1 parent 12ed6ba commit 18ed2c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/slotsComponent/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
msg: "your name is child",
},
{
default: () => [h("p", {}, "nihao")],
default: () => h("p", {}, "我是通过 slot 渲染出来的"),
}
),
]);
Expand Down
12 changes: 8 additions & 4 deletions example/slotsComponent/Child.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { h, ref, reactive } from "../../lib/mini-vue.esm.js";
import { h, ref, reactive, renderSlot } from "../../lib/mini-vue.esm.js";
export default {
name: "Child",
setup(props, context) {
},
setup(props, context) {},
render() {
return h("div", {}, "child");
return h("div", {}, [
h("div", {}, "child"),
// renderSlot 会返回一个 vnode
// 其本质和 h 是一样的
renderSlot(this.$slots, "default"),
]);
},
};

0 comments on commit 18ed2c5

Please sign in to comment.