fix(table): 修复表头同时开启 sort 和 colTool 时的事件冒泡问题 (#2954)

* fix(table): 修复表头同时开启 sort 和 colTool 时的事件冒泡问题

* Update src/modules/table.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
贤心
2025-12-25 22:13:11 +08:00
committed by GitHub
parent 8aa4ae238c
commit 050d8c0d87
2 changed files with 15 additions and 3 deletions

View File

@@ -306,8 +306,9 @@
},
{
field: 'sex',
title: '性别',
width: 80,
title:
'性别 <i class="layui-icon layui-icon-female" lay-event="gender"></i>',
width: 100,
edit: 'text',
sort: true,
escape: false
@@ -673,7 +674,13 @@
// 表头自定义元素工具事件
table.on('colTool(test)', function (obj) {
var event = obj.event;
console.log(obj);
if (event === 'gender') {
layer.alert(layui.util.escape(JSON.stringify(obj.col)), {
title: '当前列属性'
});
}
});
// 触发单元格工具事件

View File

@@ -2875,7 +2875,12 @@ layui.define(
var nowType = elemSort.attr('lay-sort');
var type;
// 排序不触发的条件
// 表头工具元素不触发排序
if ($(e.target).closest('[lay-event]')[0]) {
return;
}
// 其他条件不触发排序
if (!elemSort[0] || othis.data('resizing') === 1) {
return othis.removeData('resizing');
}