Home >Web Front-end >Vue.js >Which one is executed first, watch or mounted in vue?
mounted is executed first. The execution order of Vue life cycle hooks is: created, beforeMount, mounted, watch, beforeUpdate, updated, beforeDestroy, destroyed; the mounted hook is executed before the watch option.
Which one is executed first, watch or mounted, in vue?
Answer: mounted
Detailed explanation:
mounted is a Vue life cycle hook. When a Vue Fired when an instance is created and mounted to the DOM. watch is a Vue option used to monitor changes in data properties and execute callback functions when they change.
Therefore, the mounted hook will be executed before the watch option. This is because in the life cycle of Vue, the created, mounted, beforeUpdate, updated, beforeDestroy and destroyed hooks are triggered in sequence, and the watch option is executed after the mounted hook.
Process:
The above is the detailed content of Which one is executed first, watch or mounted in vue?. For more information, please follow other related articles on the PHP Chinese website!