samedi 11 novembre 2017

Filtering array inside a for loop throws warning VueJS

I'm not sure if this is an issue or I'm doing something wrong. Using VueJS, I have a filtering function inside a v-for and works fine, but it throws a warning in the console, this is a minimal example of the problem.

As you can see, I need to filter relational data from a different array hence the function getClan(), which returns the an array, so I need to use the data from the first element. So far so good, but when the v-for loop ends I got this warning:

[Vue warn]: Error in render function: "TypeError: this.clans.filter(...)[0] is undefined"    

The message is displayed on Chrome and Firefox console, for some reason is not displayed on codepen's local console, I'm guessing this is isolated from warnings somehow.

The warning occurs only at the end of the for loop and when trying with a larger set of the data same happens.

Thinking about using computed properties but you can't pass arguments on those.




Aucun commentaire:

Enregistrer un commentaire