What is the difference between created and mounted in the life cycle of vue?

in the life cycle of vue:
created hook: initialization of data data is completed, but el is not mounted
mounted: mount completed

I would like to ask that most ajax requests are placed in mounted, so why can"t they be placed in created? What are the disadvantages of putting it in created?
ask the boss for advice.

Mar.12,2021

who said that? It is not found in the official vue documents that it is better to put basic
in mounted and created in created. If you can request earlier, request earlier


most requests are placed in created. The advantage is that the data may be asked to come back earlier.
when placed in mounted

this.$nextTick(function () {
      Dom.
})

because sometimes your request may be dependent on the real node of the current page, and we all put it in mounted. According to theory, it is also possible in created


I have written all about it, and it doesn't feel any difference, although most of them in mounted


created put data processing, so the performance is good, otherwise dom will be refreshed if data changes are added to the mounted.

Menu