let first = this.data.date //开始时间 let second = e.detail.value //结束时间 var data1 = Date.parse(first.replace(/-/g, "/")); var data2 = Date.parse(second.replace(/-/g, "/")); var datadiff = data2 - data1; var time = 31 * 24 * 60 * 60 * 1000; console.log(first.length) console.log(second.length) if (first.length > 0 && second.length > 0) { if (datadiff < 0 || datadiff > time) { wx.showToast({ title: ‘前后时间间隔不能大于31天‘, icon: ‘none‘, duration: 2000, }) this.setData({ date1: "结束时间" }) return false; } }
原文地址:https://www.cnblogs.com/wuliujun521/p/11790881.html
时间: 2024-10-07 10:40:18