The puzzle about vue v-on $emit.

I introduced vue.js directly into the browser.
the following code. Click hi to print only hi but not hello. I don"t know why.
< div id= "app" >
< div Vlyon app Hello = "hello" >

<div v-on:click="hi">hi</div>

< / div >
< / div >
< script >
var vm = new Vue ({
el:"-sharpapp",
methods: {

hello: function() {
  console.log("hello");
},
hi: function(){
  console.log("hi");
  this.$emit("hello");
}

}
});
< / script >

Jun.01,2021

this.$emit('hello');

triggers the hello event instead of executing the hello function

Menu