记录一下,需要用到templet属性,也就是自定义列模板
参考代码:
{ field: 'oddNumbers', width: 180, title: '单号', sort: true, fixed: 'left', templet: addLink },
addLink是个方法
function addLink(d) {
var addLink = d.oddNumbers;
if ('' == addLink || null == addLink || undefined == addLink) {
return '';
}
if (addLink.length > 0) {
return '' + d.oddNumbers + '';
}
}
layui 2.2.5 开始,templet 开始支持函数形式,函数返回一个参数 d,包含接口返回的所有字段和数据。
参考链接https://www.layui.com/demo/table/style.html https://www.layui.com/doc/modules/table.html#templet
这样界面就有超链接了,如下图
一般链接会打开一个tabs或弹窗或者其它,我用的弹窗,监听表格行,获取点击行数据,如下
table.on('tool(pcList)', functi