I have this in vue data:
data() {
return {
names: [],
length: names.length,
}
But this does not work as RefereneError ( names is undefined ) is thrown. I used this.names but makes no difference.
I have this in vue data:
data() {
return {
names: [],
length: names.length,
}
But this does not work as RefereneError ( names is undefined ) is thrown. I used this.names but makes no difference.
You need to do something like this to make it work:
1st way
2nd way — using computed data (the best way):