I have this code:
     new Vue({
        el: '#app',
        components: {
            'app-component': AppComponent
        },
        data: {
            message: 'Hello Vue.js!'
        },
        methods: {
            doSomething: function(){
                console.log('arrived!')
            }
        }
    })
How can I call "doSomething" method from AppComponent html template? like this:
<app-component>  
    <a href="#" v-on:click="doSomething()">text</a>
</app-component>
I get this error:
Uncaught TypeError: scope.doSomething is not a function
You can use this, based on this answer.
this.$parent.$options.methods.someParentMethod(data)
                        try v-on:click="$parent.doSomething()"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With