示例:
setScrollLeft(){ let dataToday= new Date() let year = dataToday.getFullYear() let mounth = dataToday.getMonth()+1 let data = dataToday.getDate() let dataTimes = year+'/'+mounth+'/'+data let dataChange = new Date(dataTimes).getTime() let dataTimeLast = this.selectDateFlag.replace(/-/g,'/') let dataNow = new Date(dataTimeLast).getTime() let dataNum = Math.ceil((dataNow - dataChange)/24/60/60)/1000 -1; // alert(dataTimeLast) document.getElementById("dataSliderConts").scrollLeft = dataNum*70; this.num = dataNum*70; },
注意:时间的兼容性 在ios上会有问题