layui table单元格内标签监听点击事件
html
<table id="table" lay-filter="table"></table>
js
var $table = $('#table'); table.render({ elem: $table[0], url: '', //模拟接口 where: { }, height: 'full-100', //高度最大化减去差值 parseData: function (res) { console.log("返回数据 : ", res); return { "code": res.code == 200 ? 0 : -1, "message": res.info, "data": res.data.rows, "count": res.data.total }; }, cols: [[ { type: 'radio' }, { field: 'Name', title: '名称', minWidth: 300 }, { field: '_Operate', title: '操作', minWidth: 80, templet: '<div><a href="javascript:void(0);" lay-event="pro-view" class="layui-font-blue">测试点击事件</div>' }, ]], }); // 缩放重置表格宽高 $(document).on("resize", function (e) { table.resize('table'); }) // 监听点击事件 table.on('tool(table)', function (result) { let event = result.event; let row = result.data; console.info("click call", result); if (event === "pro-view") { // 处理你的业务逻辑 } })