Vue.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
* [[Vue.js/Navigation]] | * [[Vue.js/Navigation]] | ||
Child 偵測 Parent | == Child 偵測 Parent 數值變化方法 == | ||
=== computed in child === | |||
* this.$refs.xxx in server | |||
=== watcher in child === | |||
* 缺點 | |||
** 如果對象是 property, 需要 immediate: true | |||
** 如果對象是物件, 需要 deep: true, 但是效能會大幅下降 | |||
<source lang="js"> | |||
watcher: { | |||
foo: { | |||
handler: (newVal, oldVal) { | |||
// ... | |||
}, | |||
immediate: true, | |||
deep: true | |||
} | |||
} | |||
</source> | |||
=== this.$refs.xxx in server === | |||
Revision as of 08:14, 30 June 2021
Child 偵測 Parent 數值變化方法
computed in child
watcher in child
- 缺點
- 如果對象是 property, 需要 immediate: true
- 如果對象是物件, 需要 deep: true, 但是效能會大幅下降
watcher: {
foo: {
handler: (newVal, oldVal) {
// ...
},
immediate: true,
deep: true
}
}