vue2 call a parent function using $emit from component

Viewed 12213

i'm trying to call a parent methods from child component, but it seems not working.. here the code:

index.html

<div class="percorso"v-on:removeall="pathlengthTozero()">
</div>

component

Vue.component('lista-percorso', {
template:`
<div class="col-lg-2 col-xs-2">
    <div class="removeall pull-right" v-on:click="removeall()"></div>
</div>`,

    methods:{
    removeall : function(){
        this.listaSelezionati = [];
        this.$emit('removeall');
    }
}

parent method

    pathlengthTozero : function(){
       il_tuo_percorso = [''];
    }

seems that "pathlengthTozero" is not called on emit which is the correct way to use it?

2 Answers
Related