<!-- 生日选择器 --> <van-popup v-model="showBirthdayPicker" position="bottom"> <van-datetime-picker v-model="birthdatDate" type="date" @confirm="onConfirmBirthday" @cancel="showBirthdayPicker = false" /> </van-popup>
export default { data() { return { birthdatDate: null, showBirthdayPicker: false, form: { birthday: '' } } } }
onConfirmBirthday (e) { this.showBirthdayPicker = false var time = e.getFullYear() + '-' + this.handleDate(e.getMonth() + 1) + '-' + this.handleDate(e.getDate()) this.form.birthday = time }, handleDate(val) { return val < 10 ? '0' + val : val },