In my vue-application I want to assign prop data to an arraylist.
vue
<MyComponent :mydata="someArrayData" />
In "MyComponent" I want to do this:
props: { mydata: { type: Array, default: [] } } data(){ arrayList: [] } created(){ this.arrayList = this.$props.mydata; }
but then "this.arrayList" is empty - when I do console.log(this.$props.mydata) it returns the data.
console.log(this.$props.mydata)
what am I doing wrong here?
I actually managed to solve it by simply adding:
<div v-if="someArrayData.length"> <MyComponent :mydata="someArrayData" /> </div>
now it works for me!
Thanks for the help anyway!
2.1m questions
2.1m answers
60 comments
57.0k users