Reputation: 888
Hi guys so I'm new to vue and I know the basis even built my own app but I always asked my self when should I use mounted and created. I'm always concerned about optimization and right now I put all my code in created (fetching from API etc) but I was wondering when should I put for example axios
calls inside mounted or created for optimization purposes etc.
Upvotes: 2
Views: 2553
Reputation: 34306
You should use created
unless you need access to the element this.$el
(or any other element ref) then use mounted
instead.
There isn't really any optimization improvement using one over the other, as long as you choose a convention and stick to it.
Upvotes: 1