Skip to content

Commit

Permalink
feat: add update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jun 23, 2020
1 parent a4bcabf commit b82ade3
Show file tree
Hide file tree
Showing 11 changed files with 1,886 additions and 52 deletions.
34 changes: 30 additions & 4 deletions example/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
import { h } from "../lib/mini-vue.esm.js";
import HelloWorld from "./components/HelloWorld.js";
import { h,ref } from "../lib/mini-vue.esm.js";
// import HelloWorld from "./components/HelloWorld.js";
// import { h, ref } from "../../lib/mini-vue.esm.js";

const count = ref(1);
const HelloWorld = {
name: "HelloWorld",
setup() {},
render() {
return h(
"div",
{ tId: "helloWorld" },
`hello world: count: ${count.value}`
);
},
};

export default {
name:"App",
name: "App",
setup() {},

render() {
return h("div", { tId: 1 }, [h("p", {}, "你好,我是p"), h(HelloWorld)]);
return h("div", { tId: 1 }, [
h("p", {}, "你好,我是p"),
h(
"button",
{
onclick: () => {
count.value++;
},
},
"点我啊!"
),
h(HelloWorld),
]);
},
};
12 changes: 10 additions & 2 deletions example/components/HelloWorld.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { h } from "../../lib/mini-vue.esm.js";
import { h, ref } from "../../lib/mini-vue.esm.js";

// 临时模拟使用 refs
// 后面需要支持在 setup 内导出
// 然后在 render 内导入
// 这需要实现 proxy

const count = ref(1);
window.count = count;
export default {
name: "HelloWorld",
setup() {},
render() {
return h("div", { tId: "helloWorld" }, "hello world vue3");
return h("div", { tId: "helloWorld" }, `hello world: count: ${count.value}`);
},
};
2 changes: 1 addition & 1 deletion example/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from "../lib/mini-vue.esm.js";
import {createApp} from "../lib/mini-vue.esm.js";
import App from "./App.js";

const rootContainer = document.querySelector("#root");
Expand Down
Loading

0 comments on commit b82ade3

Please sign in to comment.