forked from vuejs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
runlong yao
committed
Aug 26, 2024
1 parent
8cae984
commit 5985fad
Showing
7 changed files
with
220 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Index</title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
|
||
</div> | ||
</body> | ||
|
||
<script type="module"> | ||
import { createApp,h,ref,defineComponent,reactive } from "../packages/vue/dist/vue.esm-browser.prod.js"; | ||
const Comp = defineComponent({ | ||
props:['data'], | ||
render(){ | ||
console.log("Comp render") | ||
return [ | ||
h("h1", `value:${this.data}`), | ||
h("h1", `${Date.now()}`) | ||
]; | ||
} | ||
}) | ||
createApp({ | ||
setup(){ | ||
// const count = ref(0) | ||
// const title = ref("这是标题") | ||
|
||
const data = reactive({ | ||
title:"这是标题", | ||
count:0 | ||
}) | ||
|
||
function inc() { | ||
data.count++ | ||
} | ||
function titleInc() { | ||
data.title = data.title + 1 | ||
} | ||
|
||
return { | ||
data, | ||
inc, | ||
titleInc | ||
} | ||
}, | ||
render(){ | ||
console.log('app render'); | ||
|
||
//vNode | ||
return [ | ||
h("h1",this.data.title), | ||
h(Comp, {data: this.data.count}), | ||
h("button", { | ||
onclick: this.inc | ||
}, "inc"), | ||
h("button", { | ||
onclick: this.titleInc | ||
}, "titleInc"), | ||
h("h1", `value:${Date.now()}`), | ||
]; | ||
} | ||
}).mount("#app"); | ||
|
||
//mount | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Index</title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
|
||
</div> | ||
</body> | ||
|
||
<script type="module"> | ||
import { createApp,h,ref,defineComponent,reactive } from "../packages/vue/dist/vue.esm-browser.prod.js"; | ||
const Comp = defineComponent({ | ||
props:['data'], | ||
render(){ | ||
console.log("Comp render") | ||
return [ | ||
h("h1", `value:${this.data}`), | ||
h("h1", `${Date.now()}`) | ||
]; | ||
} | ||
}) | ||
createApp({ | ||
setup(){ | ||
const count = ref(0) | ||
const title = ref("这是标题") | ||
|
||
// const data = reactive({ | ||
// title:"这是标题", | ||
// count:0 | ||
// }) | ||
|
||
function inc() { | ||
count.value++ | ||
} | ||
function titleInc() { | ||
title.value = title.value + 1 | ||
} | ||
|
||
return { | ||
count, | ||
title, | ||
inc, | ||
titleInc | ||
} | ||
}, | ||
render(){ | ||
console.log('app render'); | ||
|
||
//vNode | ||
return [ | ||
h("h1",this.title), | ||
h(Comp, {data: this.count}), | ||
h("button", { | ||
onclick: this.inc | ||
}, "inc"), | ||
h("button", { | ||
onclick: this.titleInc | ||
}, "titleInc"), | ||
h("h1", `value:${Date.now()}`), | ||
]; | ||
} | ||
}).mount("#app"); | ||
|
||
//mount | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Index</title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
|
||
</div> | ||
</body> | ||
|
||
<script type="module"> | ||
import { createApp,h,ref,defineComponent,reactive } from "../packages/vue/dist/vue.esm-browser.prod.js"; | ||
//内部的count只会重新渲染内部组件 | ||
const Comp = defineComponent({ | ||
setup(){ | ||
const count = ref(1) | ||
function inc() { | ||
count.value++ | ||
} | ||
return {count,inc} | ||
}, | ||
render(){ | ||
return [ | ||
h("h1", `value:${this.count}`), | ||
h("h1", `${Date.now()}`), | ||
h("button", { | ||
onclick: this.inc | ||
}, "inc"), | ||
]; | ||
} | ||
}) | ||
createApp({ | ||
setup(){ | ||
const count = ref(0) | ||
const title = ref("这是标题") | ||
|
||
// const data = reactive({ | ||
// title:"这是标题", | ||
// count:0 | ||
// }) | ||
|
||
function inc() { | ||
count.value++ | ||
} | ||
function titleInc() { | ||
title.value = title.value + 1 | ||
} | ||
|
||
return { | ||
count, | ||
title, | ||
inc, | ||
titleInc | ||
} | ||
}, | ||
render(){ | ||
console.log('app render'); | ||
|
||
//vNode | ||
return [ | ||
h("h1",this.title), | ||
h(Comp, {data: this.count}), | ||
|
||
h("button", { | ||
onclick: this.titleInc | ||
}, "titleInc"), | ||
h("h1", `value:${Date.now()}`), | ||
]; | ||
} | ||
}).mount("#app"); | ||
|
||
//mount | ||
</script> | ||
</html> |