[Vuejs]-Vue inline template not triggering method even with emit

0👍

It looks like you’re using Bootstrap Vue?

What you’re essentially doing here is putting a listener on the <b-table> tag for card-click but that event is essentially not happening within a child component of <b-table>.

Regardless, I’m not even sure you need the event.

<button @click="$emit('card-click', data)">filter</button>

can easily just be

<button @click="setUpdate(data)">filter</button>

EDIT:

It is good practice to use MVVM for Vue.js as well.

Rather than: @click="$emit('card-click', data)"

Should be: @click="onFilterClicked"

Then:

methods: {
  onFilterClicked (data) {
    this.$emit('an-event', data.some.property)
  }
}

This will make testing your code a lot easier.

Leave a comment