vue Watcher分类 computed watch
生活随笔
收集整理的這篇文章主要介紹了
vue Watcher分类 computed watch
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、Watcher構(gòu)造函數(shù)源碼部分代碼
if (options) {this.deep = !!options.deepthis.user = !!options.userthis.lazy = !!options.lazythis.sync = !!options.syncthis.before = options.before} else {this.deep = this.user = this.lazy = this.sync = false}?
2、deep watcher
deep watcher指的是深度 watcher
watch: {// 深度 watcher c: {handler: function (val, oldVal) { /* ... */ },deep: true}}可以深度監(jiān)測對象屬性的改變
?
3、user watcher
就是一般的vue的watch屬性
https://cn.vuejs.org/v2/api/#watch
?
4、computed watcher
computed watcher指的是vue下的computed屬性。
https://cn.vuejs.org/v2/api/#computed
?
總結(jié):computed和watch都是基于Watcher實(shí)現(xiàn)的。
https://cn.vuejs.org/v2/guide/computed.html
現(xiàn)在這個理解了吧,只有屬性值變化,才觸發(fā)watcher的更新。
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/mengfangui/p/10003402.html
總結(jié)
以上是生活随笔為你收集整理的vue Watcher分类 computed watch的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 纠缠于沉没成本—— 你为什么应该忽视过去
- 下一篇: css: transform导致文字显示