Skip to content

Commit

Permalink
1.更新element流程搭建;2.更新element的props
Browse files Browse the repository at this point in the history
  • Loading branch information
jindy committed Jun 14, 2022
1 parent 11b3f99 commit 4a710fe
Show file tree
Hide file tree
Showing 13 changed files with 636 additions and 133 deletions.
59 changes: 59 additions & 0 deletions example/Update/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { h,ref } from '../../lib/guide-mini-vue.esm.js'
export const App = {
neme: 'App',
setup() {
const count = ref(0)

const onClick = () => {
count.value++
}
const props = ref({
foo: 'foo',
bar: 'bar'
})

const onChangePropsDemo1 = () => {
props.value.foo = 'new-foo'
}
const onChangePropsDemo2 = () => {
props.value.foo = undefined
}
const onChangePropsDemo3 = () => {
props.value = {
foo: 'foo'
}
}
return {
count,
onClick,
props,
onChangePropsDemo1,
onChangePropsDemo2,
onChangePropsDemo3
}
},
render() {
return h(
'div',
{
id: 'root',
...this.props
},
[
h('div', {}, "count:" + this.count),
h('button', {
onClick: this.onClick,
}, 'click'),
h('button', {
onClick: this.onChangePropsDemo1,
}, 'changeProps - 值改变了 - 修改'),
h('button', {
onClick: this.onChangePropsDemo2,
}, 'changeProps - 值变成undefined - 删除'),
h('button', {
onClick: this.onChangePropsDemo3,
}, 'changeProps - 值改变了 - 删除'),
]
)
}
}
16 changes: 16 additions & 0 deletions example/Update/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>update</title>
</head>

<body>
<div id="app"></div>
<script src="./mian.js" type="module"></script>
</body>

</html>
5 changes: 5 additions & 0 deletions example/Update/mian.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from '../../lib/guide-mini-vue.esm.js'
import { App } from './App.js'

const rootContainer = document.querySelector('#app')
createApp(App).mount(rootContainer)
Loading

0 comments on commit 4a710fe

Please sign in to comment.