From 18ed2c5f093de0283d6214d4f0eb3901bbd7349d Mon Sep 17 00:00:00 2001 From: cuixiaorui Date: Mon, 22 Feb 2021 15:31:46 +0800 Subject: [PATCH] demo: update slots demo --- example/slotsComponent/App.js | 2 +- example/slotsComponent/Child.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/example/slotsComponent/App.js b/example/slotsComponent/App.js index 95689ea..a2eb47d 100644 --- a/example/slotsComponent/App.js +++ b/example/slotsComponent/App.js @@ -14,7 +14,7 @@ export default { msg: "your name is child", }, { - default: () => [h("p", {}, "nihao")], + default: () => h("p", {}, "我是通过 slot 渲染出来的"), } ), ]); diff --git a/example/slotsComponent/Child.js b/example/slotsComponent/Child.js index 7741843..c14930c 100644 --- a/example/slotsComponent/Child.js +++ b/example/slotsComponent/Child.js @@ -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"), + ]); }, };