就是想把list的time字段用getTimeLeft处理成想要的格式下面这样试了好像没有变化list:[{name:'aaa',time:1568799262000},{name:'bbb',time:1568797462000},{name:'ccc',time:1568797262000}],constutil=require('../../../utils/util.js')this.data.list.map((res)=>{this.setData({'res.time':util.getTimeLeft(res.time)})})functiongetTimeLeft(datetimeTo){lettime1=newDate(datetimeTo).getTime();lettime2=newDate().getTime();letmss=time1-time2;lethours=parseInt(mss/(1000*60*60));letminutes=parseInt((mss%(1000*60*60))/(1000*60));letseconds=parseInt((mss%(1000*60))/1000);returnhours+"时"+minutes+"分"}
2 回答
饮歌长啸
TA贡献1951条经验 获得超3个赞
this.data.list.map((res,i)=>{varstr="list["+i+"].time";this.setData({[str]:util.getTimeLeft(res.time)})
添加回答
举报
0/150
提交
取消