# 1.以对象的方式去写
v-on="{eventName:customEvent}"
~~~
<div id="app">
<p v-on="{mouseenter:enter,mouseleave:leave}">hello world</p>
</div>
~~~
~~~
new Vue({
el:"#app",
data:{
title:"test",
isShow:true
},
methods:{
enter(){
console.log("鼠标移入")
},
leave(){
console.log("鼠标移出")
}
}
})
~~~
# 2.@mouseenter,@mouseleave
~~~
<div id="app">
<p @mouseenter="enter" @mouseleave="leave">hello world</p>
</div>
~~~
~~~
new Vue({
el:"#app",
methods:{
enter(){
console.log("鼠标移入")
},
leave(){
console.log("鼠标移出")
}
}
})
~~~