B
B
BonBon Slick2020-05-23 19:35:37
Vue.js
BonBon Slick, 2020-05-23 19:35:37

Vue async mounted() when to use?

https://stackoverflow.com/questions/53513538/is-as...

In the answer from the stack, it is clear that the component will be rendered without data, which can cause errors, but there are no projectors in the example guide .

So when and how to properly use async for lifecycle hooks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-05-23
@BonBonSlick

When? When you want to.
An async function is simply a function that returns a Promise. No more.
Hooks in Vue do not use the return value in any way.
Specifically, in the example, the component starts with an array as data and only after a while loads the values.
Result? The component does not display anything for a while.
If that suits you, it's ok. You can also draw a twist while it loads.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question