[Vuejs]-Vue component data property not updating after parent data changes

0๐Ÿ‘

โœ…

You are making copies of your props, so the component renders, make your copies inside data(), but data() is called once, so when the parent component updates the child does not update.

data: function () {
    return {
        nombre_motor: this.motor.motor,
        id_motor: this.motor.id,
        id_color: this.motor.color.id,
        piezas_motor: this.motor.piezas,
    }
},

You can use motors prop directly, like:

<div class="card-header" :style="backgroundColor">
  <h4 class="text-center">
    {{ motor.motor }}
    <button class="btn btn-dark btn-sm pull-right"
      :data-motor-id="motor.id" 
      @click="show_modal_colores(motor.id)">
      Color motor
    </button>
  </h4>
</div>
๐Ÿ‘คLucas Vilaboim

0๐Ÿ‘

You need to pass value of dataMotores in components

      <card-motor :motor="dataMotores"></card-motor>
๐Ÿ‘คNiklesh Raut

Leave a comment