Skip to content

Commit e3c4838

Browse files
author
lishiwen
committed
added slots simple-demo
1 parent 2c3ec58 commit e3c4838

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

example/slots-simple/App.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { h } from "../../lib/m-vue.esm.js";
2+
import SlotInstance from "./Slot.js";
3+
import BarInstance from "./Bar.js";
4+
5+
export default {
6+
render() {
7+
const Bar = h(BarInstance);
8+
9+
// NOTE: slot example
10+
const Slot = h(
11+
SlotInstance,
12+
{},
13+
// 在Slot Children设置Slot Component, 期望可以在内部显示出来
14+
h("span", {}, "这是插入的内容")
15+
);
16+
return h("div", {}, [Bar, Slot]);
17+
},
18+
setup() {},
19+
};

example/slots-simple/Bar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { h } from "../../lib/m-vue.esm.js";
2+
3+
export default {
4+
render() {
5+
return h("div", {}, "BarComponent");
6+
},
7+
setup() {},
8+
};

example/slots-simple/Slot.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { h } from "../../lib/m-vue.esm.js";
2+
3+
export default {
4+
render() {
5+
const originalContent = h("div", {}, "这是原来的内容");
6+
return h("div", {}, [originalContent, this.$slots]);
7+
},
8+
setup() {},
9+
};

example/slots-simple/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Slots</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
</body>
12+
<script src="./main.js" type="module"></script>
13+
</html>

example/slots-simple/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createApp } from "../../lib/m-vue.esm.js";
2+
import App from "./App.js";
3+
createApp(App).mount(document.querySelector("#app"));

0 commit comments

Comments
 (0)