vue Watcher分类 computed watch
生活随笔
收集整理的這篇文章主要介紹了
vue Watcher分类 computed watch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、Watcher構造函數源碼部分代碼
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}}可以深度監測對象屬性的改變
?
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
?
總結:computed和watch都是基于Watcher實現的。
https://cn.vuejs.org/v2/guide/computed.html
現在這個理解了吧,只有屬性值變化,才觸發watcher的更新。
?
?
轉載于:https://www.cnblogs.com/mengfangui/p/10003402.html
總結
以上是生活随笔為你收集整理的vue Watcher分类 computed watch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 纠缠于沉没成本—— 你为什么应该忽视过去
- 下一篇: css: transform导致文字显示