width:30% 一直不生效时,取组件内部的id,获取宽度,再style给到标签
可复制 代码:
const columns = [
{
title: '分区字段标签',
dataIndex: 'partitionValues',
key: 'partitionValues',
width: '30%',
render: (text, record, index) => {
if (!!text) {
const box = document.getElementsByClassName('ant-table-tbody')[0];
const widthBox = box.clientWidth * 0.2;
const tooltipResult = Object.entries(text).map(res => {
return `${res[0]} = ${res[1] || '-'}`
})
return <Tooltip title={tooltipResult.join('\n')}>
{
Object.entries(text).map((res, index) => {
return <div className="only-show-one-line" key={index}
style={{maxWidth: widthBox}}>
{`${res[0]} = ${res[1] || '-'}`}
</div>
})
}
</Tooltip>
} else {
return '全部'
}
}
},