JSFiddle - React, Tailwind, and code Playground
by Md. Atiquzzaman Soikat
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<div id="app">
<child v-on:event_child="eventChild"></child>
</div>
JavaScript
Vue.component('child', {
template: '<div><button v-on:click="emit">Hello</button></div>',
methods: {
emit: function() {
this.$emit('event_child', 'Hello')
}
}
});
var vm = new Vue({
el: '#app',
data: function() {
return {
msg: 'hello vue',
}
},
methods: {
eventChild: function(message) {
console.log('Event from child component', message);
}
}
})