React+antd table中的每列內容換行


1,效果圖如下 

 

 

 

2,分隔數組split(",") 

3,詳細代碼代碼如下 

const leadsDetails = this.props.leadsDetails;
const audits = JSON.stringify(leadsDetails) !== '[]' ? leadsDetails.audits : [];

const auditsColumns = [
{
title: '創建時間',
dataIndex: 'created_at',
key: 'created_at',
},
{
title: '用戶',
dataIndex: 'user',
key: 'user',
},
{
title: '內容',
dataIndex: 'content',
key: 'content',
render: (text, record) =>{
let contentStr;
let br=<br></br>;
let result=null;
for(let i=0;i<audits.length;i++){
let contentStr=audits[i].content;
contentStr=text.toString().split(",");
if(contentStr.length<2){
return text;
}
for(let j=0;j<contentStr.length;j++){
if(j==0){
result=contentStr[j];
}else{
result=<span>{result}{br}{contentStr[j]}</span>;
}
}
return <div>{result}</div>;
}
},
},

 


 
————————————————
版權聲明:本文為CSDN博主「小紅同學5」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/xh_960125/article/details/89309547


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM