What is the difference between updated hook and watchers in VueJS?

后端 未结 2 1159
予麋鹿
予麋鹿 2021-02-07 18:18

I\'m discovering VueJS and I don\'t understand exactly the differences between updated and watchers.

Updated hook

It is a lifecycle hook. Accordin

2条回答
  •  悲哀的现实
    2021-02-07 19:03

    The lifecycle hooks around update respond to changes in the DOM. Watchers respond to changes in the data. DOM changes are generally in response to data changes, but they might not be data owned by the component in question. One example where updated could be used is noticing that slot content has updated.

提交回复
热议问题