Vue.js - Which component lifecycle should be used for fetching data?

后端 未结 3 2165
渐次进展
渐次进展 2021-02-13 16:48

After reading one of Alligator.io posts about Vue that was saying that mounted lifecycle is a bad place to use http get. I was wondering if there are any guidelines to how prope

3条回答
  •  轮回少年
    2021-02-13 17:35

    The answers make sense but if we use the mounted() hook to call the API's, Assuming that the DOM is rendered. If we update a state here in mounted() will it trigger another render ?

    I am sure that in created() hook the DOM is not yet mounted. So, I might go with created().

提交回复
热议问题