Skip to content

Commit cf715c7

Browse files
author
lishiwen
committed
feat: getCurrentInstance example
1 parent 9697f42 commit cf715c7

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

example/CurrentInstance/App.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { h, getCurrentInstance } from "../../lib/m-vue.esm.js";
2+
import Foo from "./Foo.js";
3+
4+
export default {
5+
name: "App",
6+
render() {
7+
return h("div", {}, [h("p", {}, "Current Instance"), h(Foo)]);
8+
},
9+
setup() {
10+
const instance = getCurrentInstance();
11+
console.log("App", instance);
12+
},
13+
};

example/CurrentInstance/Foo.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { h, getCurrentInstance } from "../../lib/m-vue.esm.js";
2+
3+
export default {
4+
name: "Foo",
5+
render() {
6+
return h("div", {}, "Foo");
7+
},
8+
9+
setup() {
10+
const instance = getCurrentInstance();
11+
console.log("Foo", instance);
12+
},
13+
};

example/CurrentInstance/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>CurrentInstance</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
</body>
12+
<script src="./main.js" type="module" charset="utf-8"></script>
13+
</html>

example/CurrentInstance/main.js

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

0 commit comments

Comments
 (0)