[Vuejs]-How to send 2 params for event in javascript

1👍

new Vue({
  el: '#app',
  data() {
    return {
      book: {
        bookTitle: 'title'
      }
    }
  },
  methods: {
    getUser(e, book) {
      console.log(book);
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>

<div id="app">
  <input type="button" :value="book.bookTitle" @click="getUser($event,book)" />
</div>
👤sugars

0👍

Based of this answer. If you want to get the event in your getUser method, use $event in your binding. Like this:

<td>
  <input type="text" :value="book.bookTitle" @click="getUser(book, $event)" @keyup="save" />
</td>
👤Stutje

Leave a comment