<van-field v-model="form.sendDate" label="开始日期:" input-align="right" is-link readonly required :rules="[{ required: true, message: '请选开始时间' }]" @click="showDatePicker=true;selectDate=1;"> </van-field> <van-field v-model="form.finishTime" label="完成时间:" input-align="right" is-link readonly required :rules="[{ required: true, message: '请选择完成时间' }]" @click="showDatePicker=true;selectDate=2;"> </van-field> /***************************** ***********/ //日期弹窗组件 <van-popup v-model="showDatePicker" position="bottom" :style="{ height: '40%' }" > <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @confirm="confirmDatePicker" @cancel="cancelDatePicker" /> </van-popup> /*************************************************/ //在data中维护一个状态 selectDate: 0, showDatePicker: false, //逻辑部分 confirmDatePicker(v) { v = new Date(v).toLocaleDateString().replace(///g, '-') console.log(v) this.selectDate == 1 ? this.form.sendDate = v : this.selectDate == 2 ? this.form.finishTime = v : '' this.showDatePicker = false; },