在这里,我有一个带有3个值的“活动”数组。我正在映射该值并显示在下面。但是我必须显示created_at是今天的日期,如果它的最后一天是昨天,则应该在下面的标签上显示今天,昨天和其余所有都应显示相同的值,例如“ 2019-07-09”。 我也可以获取今天的日期和昨天的日期,但在我看来无法显示。其次,我的消息响应来自html标签,我该如何更改它并在我的本机视图中显示。请帮忙。
let today =new(Date);
let Yesterday=new Date(today);
Yesterday.setDate(today.getDate() - 1);
const { navigation,isLoading,notifications } = this.props;
active: Array(3)
0:
created_at: "2019-07-09T14:38:44.442Z"
expires_at: "2019-12-29T00:00:00.000Z"
message: "<p>Long notification test Long notification test Long notification test Long notification test Long notification test Long notification test Long notification test Long notification test</p>"
status: 1
title: "Long notification test again"
__typename: "NotificationList"
_id: "5a4653746e8fe500370fd744"
1:
created_at: "2019-02-25T12:42:02.966Z"
expires_at: "2020-05-31T00:00:00.000Z"
message: "<p>Hi Hello</p>"
status: 1
title: "Hi Hello"
__typename: "NotificationList"
_id: "5c73e29a77939a0036af7631"
2:
created_at: "2018-07-10T13:29:45.713Z"
expires_at: "2019-12-25T00:00:00.000Z"
message: "<p>This is testing annoucement</p>"
status: 1
title: "testing annoucement"
__typename: "NotificationList"
_id: "5a5cacc9a67c2c004befb146"
{notifications.notificationList.active.map((data,index) =>{
return(
<View key={index}>
<View style={{flexDirection:'column', backgroundColor:'white'}}>
<Label text= {`${data.created_at}`}/>
<Heading title={`${data.title}`} time="9.00 am"/>
<Content text={`${data.message}`}/>
</View>
</View>
)
})}
谢谢