Mouseover or hover vue.js

前端 未结 13 1674
温柔的废话
温柔的废话 2021-01-30 02:13

I would like to show a div when hovering over an element in vue.js. But I can\'t seem to get it working.

It looks like there is no event for hover or mouseover in vue.j

相关标签:
13条回答
  • 2021-01-30 02:48

    There's no need for a method here.

    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
      }
    })
    
    0 讨论(0)
提交回复
热议问题