Vue2文档写的很清楚,红色空心框中的文字皆为生命周期钩子 (before + ed):
- create x2 [beforeCreate & Cteated]
- mount x2 [beforeMount & Mounted]
- update x2 [beforeUpdate & updated]
- destroy x2 [beforeDestroy & destroyed]
还有三个写在钩子列表里:
- activated
- deactivated
- errorCaptured
请求放在mounted里面,因为放在其他地方都不合适