在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 關(guān)于vue v-on $emit 的不解。

關(guān)于vue v-on $emit 的不解。

我是瀏覽器直接引入 vue.js 的。
以下代碼。點擊hi只打印 hi 不打印 hello。不知為何。
<div id="app">
<div v-on:hello="hello">

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

</div>
</div>
<script>
var vm = new Vue({
el:'#app',
methods: {

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

}
});
</script>

回答
編輯回答
菊外人
this.$emit('hello');

是觸發(fā)hello事件,而不是執(zhí)行hello函數(shù)

2017年11月5日 10:25