以下代码是渲染函数的返回值
this.props.investment.selectedInvestor.rounds.map((item,index)=>{
if(item.type.toLowerCase()==this.state.securityType.toLowerCase())
{
return(
<tr onClick={()=>this.showRoundDetails(true,item)}>
<td>
<strong>{item.round_name}</strong><br/>
<span>{item.close_date}</span>
</td>
<td>{item.security_type}</td>
<td>{item.sharing_plan}</td>
<td>{item.investments[0].status}</td>
<td>{item.rate}</td>
<td>{item.frequency}</td>
<td>{item.investments[0].current_amount}</td>
</tr>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我想转换{item.close_date}为另一种格式,即使用此函数toLocaleDateString()
我尝试在 return 之外声明另一个变量,然后转换日期,但仍然无法解决
{item.close_date}是您在评论中提到的字符串(包含日期),要toLocaleDateString()首先使用方法,您需要将该字符串转换date object为 using new Date(),然后您可以使用任何日期方法。
用这个:
<span>{ (new Date(item.close_date)).toLocaleDateString() }</span>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2728 次 |
| 最近记录: |