在vue中,使用@click点击事件没有任何问题
<el-button type="primary" icon="el-icon-plus" @click="searchBtn">添加用户</el-button>
但是将@click替换为@mouseenter、@mousedown等鼠标事件[非鼠标点击事件]时,发现事件不触发(也就是失效了)
此时应该在@mouseenter、@mouseenter等鼠标事件加上native属性就好了
<el-button type="primary" icon="el-icon-plus" @mouseenter.native="searchBtn">添加用户
</el-button>
在 Vue 框架中,使用 @click 事件处理点击无误,但遇到 @mouseenter 和 @mousedown 等非点击事件时,事件监听失效。解决方法是在非点击事件上添加 .native修饰符,如 @mouseenter.native,以确保在组件元素上正确触发。此问题涉及到 Vue 的事件绑定机制和事件修饰符的使用。
870





