[Vuejs]-Component methods do not fire in Vue

0👍

You need to add template to component options:

Vue.component('test-component', {
   template: ` <form>
    <!-- a bunch of HTML markup here... -->
    <button type="button" @click="testMethod">Fire a test method...</button>
</form>`,
  //..

});
👤xAoc

0👍

You should add a template:

Vue.component('test-component', {
    data() {
        return {
            someData: '' // does work!
        };
    },
    template: '<div></div>', // add your template here
    mounted() {
        console.log('ready'); // does not fire...
    },
    methods: {
        testMethod() {
            console.log('here'); // does not fire...
        }
    }
});
👤Nora

Leave a comment