[Vuejs]-Vuejs: How to properly pass props to component data

0👍

You should used computed instead.

Vue.component('lista-servizi', {
  //...
  computed: {
    listaServizi() {
      return this.servizi
    }
  }
}

0👍

Most likely you have a problem with modello.
By defining the modello, your code works fine. Below is an example based on your code that works:

<div id="app-1">
<lista-servizi :servizi="modello"></lista-servizi>
</div>



Vue.component('lista-servizi', {
  template: '<span class="blu">{{listaServizi.lineaGialla.descrizione}}</span>',
  props: ['servizi'],
  data: function(){
    return{
     listaServizi : this.servizi
    }
  }
})

var app1 = new Vue({
 el: '#app-1',
 data: {
 modello: { 
  lineaGialla : {
    descrizione : " This is a description"
    }
  }
}
})

Here is a link to a working bin
https://jsbin.com/qoloqoz/1/edit?html,js,output

Leave a comment