console
Vue.config.keyCodes.f1 = 112
var vm = new Vue({
el: '#app',
data: function(){
return {
num: 0,
messages: ["在事件名称后面加上.stop可以调用event.stopPropagation"]
}
},
methods: {
showAlert: function(arg){
alert(arg)
},
handlerEvent: function(e){
alert(e.currentTarget.value)
}
}
})
<div id="app">
<div @click="showAlert('parent')">
<div>{{messages[0]}}</div>
<button @click.stop="showAlert('children')">click</button>
</div>
<div><input type="text" placeholder="请输入一段文字" @keyup.enter="handlerEvent($event)"/></div>
<div><input type="text" placeholder="请输入文字,按下F1" @keyup.f1="handlerEvent($event)"/></div>
</div>
#app{
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
max-width: 750px;
text-align: center;
}