我尝试将下面列中的日期格式设置为“DD/MM/YYYY”,并且标题行与数据不对齐,如何解决此问题?
我正在使用该功能
function dateFormatter(cell: any) {
var d = (moment(new Date('${cell}').toLocaleDateString()).format("DD/MM/YYYY"));
return d;
}
并在 TableHeaderColumn 中:
<TableHeaderColumn dataField='effectiveDate' dataSort={true} dataFormat={dateFormatter} >Effective Date</TableHeaderColumn>
最佳答案
试试这个 - 它适用于我的情况
function dateFormatter(cell: any) {
if (!cell) {
return "";
}
return `${moment(cell).format("DD-MM-YYYY")? moment(cell).format("DD-MM-YYYY"):moment(cell).format("DD-MM-YYYY") }`;
}
关于reactjs - React Bootstrap 表中的日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50960984/