// 因为表格可以拖动设置宽度,所以需要用js设置初始宽度 function setBasicParamTableWidth() { const basicParamDom = $('.fixTableCss') let dom = [] try { dom = basicParamDom.find('table').find('thead').children().children() } catch { dom = [] } if (!dom) return dom.each(function () { if ($(this).hasClass('row_no') >= 0) { // 序号列 // 不设置 通过css设置 } const text = $(this).text() $(this).find('span').removeClass('text-truncate') if (text.length > 5) { $(this).width('150px') } else if (text.length == 5) { $(this).width('100px') } else if (text.length == 4) { $(this).width('80px') } else if (text.length == 3) { $(this).width('65px') } else if (text.length == 2) { $(this).width('50px') } }) } setTimeout(setBasicParamTableWidth, 500)