[Vuejs]-How to setup a property class to extend on all components on VueJS project?

0👍

I would emit a global event and make all related components listen for it.

// button function
function deleteHandler() {
  this.$root.$emit('<meeting-id>', {action: 'delete'})
}

// on your-component
{
  props: {
    meetingId: {
      type: String,
      default: 'meeting-id'
    }  
  }
  data: {
    noText: ''
  },
  mounted() {
    this.$root.$on(this.meetingId, (payload) => {
      if(payload.action === 'delete') this.setNoTextClass
    }
  }
}

in your HTML

<your-component 
  :class="[noText, 'grey--text']" 
  key="meetingsListTab">
Reuniões
</your-component>

References:

Leave a comment