鼠标悬停或悬停 vue.js
我想在 vue.js 中将鼠标悬停在一个元素上时显示一个 div.但我似乎无法让它工作.
I would like to show a div when hovering over an element in vue.js. But I can't seem to get it working.
vue.js 中的 hover
或 mouseover
似乎没有事件.这是真的吗?
It looks like there is no event for hover
or mouseover
in vue.js. Is this really true?
可以结合jquery hover和vue方法吗?
Would it be possible to combine jquery hover and vue methods?
推荐答案
这里不需要方法.
HTML
<div v-if="active">
<h2>Hello World!</h2>
</div>
<div v-on:mouseover="active = !active">
<h1>Hover me!</h1>
</div>
JS
new Vue({
el: 'body',
data: {
active: false
}
})
相关文章