doUWannaBuildASnowMan
doUWannaBuildASnowMan

Reputation: 461

Why @mouseover action in vue cannot work

The mouseover action cannot work; it cannot console.log the message when I mouseover

code

<template>
  <div id="horrizontalNav">
    <el-menu class="el-menu-demo" mode="horizontal" >
      <el-menu-item index="1" @mouseover="showUp">find Music</el-menu-item>
    </el-menu>

  </div>
</template>

<script>
  export default {
    data() {
      return {
      };
    },
    methods: {
      showUp() {
        console.log('succeed')
      }
    },
  }
</script>

Upvotes: 10

Views: 17350

Answers (1)

Tomer
Tomer

Reputation: 17930

Since you are putting the event on a custom element, you have to use the native modifier:

<el-menu-item index="1" @mouseover.native="showUp">find Music</el-menu-item>

see more here: https://v2.vuejs.org/v2/guide/components.html#Binding-Native-Events-to-Components

Upvotes: 32

Related Questions