[Vuejs]-Vue JS methods not firing

2👍

When used as a standalone component the problem you described doesn’t occur. Your problem must lie elsewhere, in code you haven’t shown above.

Vue.component('sample', {
  template: '<button id="get-listings" v-on:click="getValue">{{name}}</button>',
  data() {
    return {
      name: 'foo',
    };
  },
  methods: {
    getValue() {
      console.log('get value');
    }
  }
});

var vm = new Vue({
  el: '#app'
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<div id="app">
  <sample></sample>
</div>

Leave a comment