記錄源碼中的知識點
- 1、Vue加載數據狀態先後順序:
props->data->computed->watch
- 2、收集依賴是
defineReactive
中的get
觸發更新是函數中的set
- 3、一個組件一般固定一個
watcher
,存有組件的update(render)
更新函數,除了固定函數外還有normal-watcher
computed-watcher
兩種。 - 4、
Vue
data每個對象包括子對象都擁有一個Dep 的實例對象,dep對象只有id``subs
兩個屬性。主要是在dep.notify->forEach(watcher.update)->watcher.run-> expression
- 5、
props
在傳入子組件後屬性再次被defineReactive
加入當前組件watcher依賴,並賦予又一個dep,同時Object.defineProperty
將會被覆蓋。