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

后端 未结 2 802
情歌与酒
情歌与酒 2021-02-07 18:39

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:07

    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.

提交回复
热议问题