[Vuejs]-Onclick with Vue.JS

0👍

You can do this by having the attribute v-on:click="filterSelection(genre)" on your button.

Edit: Forgot quotes.

0👍

Since vue uses a virtual dom, you cannot use the "native html" events.

Instead you define click events via an event handler [docs]

<div id="example-1">
  <button v-on:click="counter += 1">
    Add 1
  </button>
  <p>
    The button above has been clicked {{ counter }} times.
  </p>
</div>

alternatively you can use the shorthand for v-on and use the @ symbol like @click=

Leave a comment