【问题标题】:Can I use DateField with timestamp value in react-admin?我可以在 react-admin 中使用带有时间戳值的 DateField 吗?
【发布时间】:2019-02-27 23:51:05
【问题描述】:

我有时间戳(字符串)值。 我可以使用带时间戳的 DateField 吗?

<DateField source="createdAt" showTime /> // createAt: timeStamp(String)

【问题讨论】:

    标签: react-admin


    【解决方案1】:

    将您的时间戳转换为整数,例如使用自定义组件:

    const DateFieldForTimestamp = props => {
        const recordWithTimestampAsInteger = {
            [props.source]: parseInt(props.record[props.source], 10)
        };
        return <DataField {...props} record={recordWithTimestampAsInteger} />
    }
    

    【讨论】:

    • DataField 应该是 DateField
    猜你喜欢
    • 2020-03-30
    • 2016-04-08
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 2019-10-21
    相关资源
    最近更新 更多