last day (15 days later) » 

7:49 AM
0
A: Passing data from parent to child via props in v-for in VueJS 2

Ezequiel FernandezYou should populate itemsData in computed method using ...mapState Parent.vue export default { data: function () { return { items: this.itemsData } }, computed:{ ...mapState('module/namespace', ['itemsData']) } } <div class="col-sm-2" v-for="(item,index) in items" :k...

 
Read the question, please. I have added mapState
 
mapState could go in computed and not in created instead!
 
Yes in the computed
 
update the question with the code in your parent! :)
 
Updated! Please check
 
7:49 AM
1- Can you print please <pre>itemsData</pre> in the template and check the data there? 2- can you please see where is the error coming from? I am guessing is from the child component .
 
1. Yes I have set sample data as shared above. 2. Yes from child component
 
maybe axios take some time to get the data and the component wants to render it. take this try:
updated please check
 
[Vue warn]: The computed property "itemsData" is already defined in data.
 
do you have more stuff in data(){} ? itemsData should be declared there
 
if I use items instead of Itemdata my vue will not be reactive
I need to use itemata
itemData
 
7:56 AM
have you tried to update the prop in child one
?
props: {
type: Object,
default: null
}
or
props: {
type: Object,
required: true
}
 

last day (15 days later) »