[英]Display two dates in react
I want to display two dates in my react application. 我想在我的应用程序中显示两个日期。 It should be displayed as Date1 - Date2.
它应显示为Date1-Date2。 Here is the code.
这是代码。
export const formatFromToDates = (fromDate, toDate) => {
return (
<Moment format='YYYY/MM/DD'>{fromDate}</Moment> -
toDate === null ? ' Now' : <Moment format='YYYY/MM/DD'>{toDate}</Moment>
);
}
But is only displays the second date. 但是只显示第二个日期。 How should I do this?
我应该怎么做?
You've forgotten to put {}
around your JSX expression for toDate
: 您忘了在
{}
周围加上toDate
的JSX表达式:
export const formatFromToDates = (fromDate, toDate) => {
return (
<Moment format='YYYY/MM/DD'>{fromDate}</Moment> -
{toDate === null ? ' Now' : <Moment format='YYYY/MM/DD'>{toDate}</Moment>}
// -----^------------------------------------------------------------------------^
);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.