I am very new in Vue JS. I am following Vuejs documentation and trying to emit a value with click event. Somehow I am making mistakes that's why it is not working.
So I am sorry if the question is some kind of obvious.
The code is something like this:
Vue Template:
<div id="app">
<div class="container">
<div class="col-lg-offset-4 col-lg-4">
<sidebar v-on:incrementBtn="increment += $event"></sidebar>
<p>{{ increment }}</p>
</div>
</div>
</div>
Vue instances:
Vue.component('sidebar',{
template:`
<div>
<button class="btn btn-info" v-on:click="$emit('incrementBtn', 1)">Increment on click</button>
</div>
`,
});
new Vue ({
el:'#app',
data:{
increment:0
}
});
Check Vue Custom Event, Vue always recommends using kebab-case for event names.
And as above Vue guide said:
And