<template>
<el-table :data="tableData" @row-click="handleRowClick" @row-dblclick="handleRowDblclick">
</el-table>
<el-drawer :visible.sync="drawerVisible" :with-header="false" size="50%">
</el-drawer>
</template>
<script>
export default {
data() {
return {
tableData: [],
drawerVisible: false,
clickTimer: null
};
},
methods: {
handleRowClick(row, column, event) {
// 清除之前的定时器
clearTimeout(this.clickTimer);
// 设置一个定时器,如果是双击,定时器不会执行
this.clickTimer = setTimeout(() => {
this.drawerVisible = true;
// 这里处理单击事件
}, 200); // 200毫秒内没有第二次点击则认为是单击
},
handleRowDblclick(row, column, event) {
// 清除定时器,防止单击事件触发
clearTimeout(this.clickTimer);
// 这里处理双击事件
}
}
};
</script>
el-table 单击打开 el-drawer 单击和双击冲突
最新推荐文章于 2024-08-13 16:35:40 发布