A
A
ArtJH2019-07-23 15:08:21
Vue.js
ArtJH, 2019-07-23 15:08:21

The Vue component has a @click="remove" function. How to call this function inside the main vue?

Vue.component('add-edu', {
  template: `
    <div class="gray_dashed">
      <i class="fas deleteForm fa-times" v-on:click="remove"></i>	
    </div>
`
});

new Vue({
  el: '.midMain',
  	data: {
  		mes: 'sds'
  	},
  	methods:{
  		remove: function() {
  			this.mes = 'Привет';
  		}
  	}
});

Issue: button not responding

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-07-23
@ArtJH

You don't need it. Generate an event in the child component, subscribe to it in the parent component and call the desired method in the handler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question