日期转换为数组

做项目的时候,后端给返回的时间数据是 2017-3的格式,但是UI图上要求为2017年3月呈现;

所以我们要把后端返回的数据进行一定的处理,拼接;

2017-3 变为 2017年3月

我们用split(‘-‘)将2017-3变为数组 [“2017”, “3”],然后就可以拿去拼接了;

后台给返的的数据是 data[0].registDate,现在变成:

{data[0].registDate.split("-")[0]}年
{data[0].registDate.split("-")[1]}月

猜你喜欢

转载自blog.csdn.net/love_your_life/article/details/80114425