23
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vue.jsでmouseoverした時だけ表示する方法

Posted at

jQueryだと、mouseoverを使うことになると思います。

ただし、vueで使用すると、mouseoverした瞬間だけ、メソッドが実行されます。

なんで、正確にmouseoverした時だけ表示する方法です。

結論から言うと、mouseentermouseleaveを使います。

vue.js
  const topicForm = Vue.extend({
    data: function() {
      return {
        LinkIconActive: false,
        ImageIconActive: false
      }
    },
    methods: {
      LinkIconDescriptionShow: function() {
        return this.LinkIconActive = true
      },
      LinkIconDescriptionHidden: function() {
        return this.LinkIconActive = false
      }
    }
  })

html.slim
i.fa.fa-link.@mouseenter="LinkIconDescriptionShow" @mouseleave="LinkIconDescriptionHidden"

methodsが二つ生えて、ダサいけど、こんな感じになるかと思います。

もっといい書き方があれば、教えて下さいm(_ _)m

23
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?