-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
69 lines (61 loc) · 1.72 KB
/
App.js
File metadata and controls
69 lines (61 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Author:
* Date: 22.12.7
* Description:
*/
// 竟然还能这样import
import {h, reactive} from "./core";
export default {
// template => render
render (context) {
// const element = document.createElement('div')
// const text = document.createTextNode('这是一个响应式count计数: ')
// const text1 = document.createTextNode(context.obj.count)
//
// element.append(text)
// element.append(text1)
// return element
// --------------------------------------------------------------------------------------
// 虚拟dom第一步
// return h('div', {id: 'sam', class: 'border'}, [
// h('p', {}, '这是一个响应式count计数'),
// h('p', {}, String(context.obj.count))
// ])
// diff测试用例
// test diff tag
// return h(context.obj.tag, {}, '1')
// test props 1 add
// return h('div', context.obj.props, '1')
// test props 2 remove
// return h('div', context.obj.props, '1')
// test children new string - old string/array
// return h('div', {}, context.obj.children)
// test children new Array - old string
// return h('div', {}, context.obj.children)
// test children old Array new Array
return h('div', {}, context.obj.children)
},
setup () {
const obj = reactive({
count: 1,
tag: 'div',
props: {
a: 'a',
b: 'b'
},
// children直接输入数字1,会有问题,因为mount的逻辑判断到
children: [
h('div', {}, '111'),
],
childrenNew: [
h('div', {}, 'aaa'),
h('div', {}, 'bbb'),
]
})
// 将响应式数据暴露到window上,方便调试
window.obj = obj
return {
obj
}
}
}