vue2 el-table行悬停时弹出提示信息el-popover的实现
更新时间:2024年01月12日 11:52:29 作者:黑睿
本文主要介绍了vue2 el-table行悬停时弹出提示信息el-popover的实现,用到了cell-mouse-enter、cell-mouse-leave两个事件,具有一定的参考价值,感兴趣的可以了解一下
实现方法,用到了cell-mouse-enter、cell-mouse-leave两个事件,然后在表格的首列字段中,加个el-popover组件,当然你也可以选择在其他字段的位置来显示提示框,看自己的需求了。

示例代码:
<el-table @cell-mouse-enter="enter" @cell-mouse-leave="leave" :data="[{rowIndex:100, title:'行一', status: 1},{rowIndex:200, title:'行二', status: 0}]">
<el-table-column label="序号" width="100">
<template slot-scope="scope">
<el-popover trigger="manual" placement="right" :ref="'popover'+(scope.row.rowIndex)">
<div>弹出popover提示内容</div>
<div slot="reference">{{ scope.$index+1 }}</div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="标题" prop="title"></el-table-column>
</el-table>enter (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = true
},
leave (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = false
}在enter方法中,还可以根据row行数据进行一些处理,比如根据状态status来判断是否弹出提示框。
enter (row, column, cell) {
//当status等于0时弹出提示框
if(row.status===0) {
this.$refs['popover' + row.rowIndex].showPopper = true
}
},
leave (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = false
}到此这篇关于vue2 el-table行悬停时弹出提示信息el-popover的实现的文章就介绍到这了,更多相关vue2 悬停弹出提示信息内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Vue3 企业级组件库框架搭建 pnpm monorepo实战示例
这篇文章主要为大家介绍了Vue3 企业级组件库框架搭建 pnpm monorepo实战示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-11-11
Vue踩坑之Vue Watch方法不能监听到数组或对象值的改变详解
Vue 提供了一种更通用的方式来观察和响应 Vue 实例上的数据变动:侦听属性,下面这篇文章主要给大家介绍了关于Vue踩坑之Vue Watch方法不能监听到数组或对象值的改变的相关资料,需要的朋友可以参考下2022-04-04
vue quill editor 使用富文本添加上传音频功能
vue-quill-editor 是vue项目中常用的富文本插件,其功能能满足大部分的项目需求。这篇文章主要介绍了vue-quill-editor 富文本添加上传音频功能,需要的朋友可以参考下2020-01-01


最新评论