解决方法:
<uni-forms-item class="form-item" label="入校日期" name="sqrxrq" required> <!-- :minDate="mindate()" :maxDate="maxdate()" --> <u-datetime-picker @confirm="ggff" @cancel="gghh" :minDate="mindate()" :maxDate="maxdate()" :formatter="formatter" :show="show" v-model="value1" mode="datetime"></u-datetime-picker> <uni-easyinput clearSize="0" style="z-index: 10;" prefixIcon="calendar-filled" v-model="model.sqrxrq" placeholder="选择时间" @focus="ffss"></uni-easyinput> </uni-forms-item> <uni-forms-item class="form-item" label="结束日期" name="sqrxjssj" required> <u-datetime-picker @confirm="ggffOne" @cancel="gghhOne" :minDate="mindateOne()" :maxDate="maxdateOne()" :formatter="formatter" :show="showOne" v-model="value2" mode="datetime"></u-datetime-picker> <uni-easyinput :disabled="model.sqrxrq == ''" clearSize="0" prefixIcon="calendar-filled" v-model="model.sqrxjssj" placeholder="选择时间" @focus="ffssOne"></uni-easyinput> </uni-forms-item>
maxdate() { let currentDate = new Date(); let year = currentDate.getFullYear(); let month = ("0" + (currentDate.getMonth() + 1)).slice(-2); let day = ("0" + currentDate.getDate()).slice(-2); // 设置当前日期为下个月的第一天 let firstDayOfNextMonth = new Date(year, month, 1); // 获取当前月份的最后一天 let lastDayOfMonth = new Date(firstDayOfNextMonth.getTime() - 1); let lastDay = lastDayOfMonth.getDate(); // if (Number(day) + 3 > lastDay) { // month = month * 1 + 1 // day = Math.abs(day - lastDay); // } else { // day = Number(day) + 3 // } if (uni.getSystemInfoSync().platform == 'ios') { if (Number(day) + 3 > lastDay) { month = month * 1 + 1 day = Math.abs(day - lastDay); } else { day = Number(day) + 3 } let ss = year + '/' + month + '/' + day + ' ' + '23:59:59' return Date.parse(ss); } if(uni.getSystemInfoSync().platform == 'android') { if (Number(day) + 3 > lastDay) { month = month * 1 + 1 day = Math.abs(day - lastDay); } else { day = Number(day) + 3 } let ss = year + '-' + month + '-' + day + ' ' + '23:59:59' return Date.parse(ss); } }, maxdateOne() { if (this.model.sqrxrq) { let ss = this.model.sqrxrq.slice(0, 10); let ff = ss + ' ' + '23:59:59' return Date.parse(ff); } }, mindate() { let currentDate = new Date(); let year = currentDate.getFullYear(); let month = ("0" + (currentDate.getMonth() + 1)).slice(-2); let day = ("0" + currentDate.getDate()).slice(-2); let ss = year + '-' + month + '-' + day + ' ' + '00:00:00' return Date.parse(ss); }, mindateOne() { if (this.model.sqrxrq) { return Date.parse(this.model.sqrxrq); } },