File tree 2 files changed +13
-9
lines changed
2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
// 设置不检查 JavaScript 的语法问题,防止 flow 报错
3
3
"javascript.validate.enable" : false ,
4
- "commentTranslate.source" : " Bing"
4
+ "commentTranslate.source" : " Bing" ,
5
+ "liveServer.settings.port" : 5501
5
6
}
Original file line number Diff line number Diff line change 12
12
又会使用 src\shared\util.js 中的 toString 方法将该 msg 对象转成字符串,
13
13
此时又会进行一次依赖收集
14
14
-->
15
- <!-- < h3>{{ msg }}</h3> -- >
16
- < ul >
15
+ < h3 > {{ msg }}</ h3 >
16
+ <!-- < ul>
17
17
<li v-for="item in items">{{ item }}</li>
18
- </ ul >
18
+ </ul> -->
19
19
< button @click ="add "> add</ button >
20
20
< button @click ="change "> change</ button >
21
21
</ div >
46
46
el : '#app' ,
47
47
data ( ) {
48
48
return {
49
- // msg: {
50
- // a: 'hello'
51
- // },
52
- items : [ 1 , 2 ]
49
+ msg : {
50
+ a : 'hello'
51
+ } ,
52
+ // items: [1, 2]
53
53
}
54
54
} ,
55
55
methods : {
66
66
// this.msg.b = 'Vue'
67
67
68
68
// 正确写法
69
- Vue . set ( this . msg , 'b' , 'Vue' )
69
+ // Vue.set(this.msg, 'b', 'Vue')
70
+ // Object.assign 能够生效是由于 defineReactive setter 中的 “childOb = !shallow && observe(newVal)” 这样代码,
71
+ // 即会对传入的 对象 重新做依赖收集!
72
+ this . msg = Object . assign ( { } , this . msg , { b : 'Vue' } )
70
73
71
74
// 错误写法
72
75
// this.items[2] = 4
You can’t perform that action at this time.
0 commit comments