Vue2的生命周期钩子有哪些

64 阅读1分钟

Vue2文档写的很清楚,红色空心框中的文字皆为生命周期钩子 (before + ed):

  1. create x2 [beforeCreate & Cteated]
  2. mount x2 [beforeMount & Mounted]
  3. update x2 [beforeUpdate & updated]
  4. destroy x2 [beforeDestroy & destroyed]

image.png

还有三个写在钩子列表里:

  1. activated
  2. deactivated
  3. errorCaptured

请求放在mounted里面,因为放在其他地方都不合适