[Vuejs]-Vue.js: Assigning computed result to data property at created or mounted?

0๐Ÿ‘

โœ…

As is often the case, the unexpected result was because of something outside the logic of the particular question. In my case, my parentArray was coming from an axios call, which is async, which meant that it did not arrive until AFTER the component was mounted, and hence my empty array. Adding a check for loaded data (by setting data item loaded to false, then setting it to true in my axios response and finally adding v-if="loaded" to my component made it work as expected.

So the answer to the question above is YES, this is possible (BUT make sure your parent prop data is available before mounting).

Leave a comment