Why @mouseover action in vue cannot work

有些话、适合烂在心里 提交于 2019-12-10 17:50:34

问题


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>

回答1:


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://vuejs.org/v2/guide/components.html#Binding-Native-Events-to-Components



来源:https://stackoverflow.com/questions/46293996/why-mouseover-action-in-vue-cannot-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!