gpt4 book ai didi

vue.js - 为什么 vue 中的 @mouseover Action 不起作用

转载 作者:搜寻专家 更新时间:2023-10-30 22:14:32 30 4
gpt4 key购买 nike

鼠标悬停 Action 无效;当我将鼠标悬停在

上时,它无法控制台记录消息

代码

<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>

最佳答案

由于您将事件放在自定义元素上,因此您必须使用 native 修饰符:

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

在这里查看更多信息:https://v2.vuejs.org/v2/guide/components.html#Binding-Native-Events-to-Components

关于vue.js - 为什么 vue 中的 @mouseover Action 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46293996/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com