Files
electricity_bill_calc_wx/components/DateTimePicker/index.js
2025-09-17 16:48:57 +08:00

51 lines
1010 B
JavaScript

// components/datePicker/index.js
import dayjs from "../../utils/dayjs"
Component({
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
// time: String,
},
// observers: {
// time: function(newValue) {
// console.log("time newValue", newValue)
// if (!newValue) {
// return;
// }
// this.setData({
// currentDate: new Date(newValue).getTime(),
// })
// }
// },
/**
* 组件的初始数据
*/
data: {
currentDate: new Date().getTime(),
maxDate: new Date().getTime(),
minDate: new Date(2024, 1, 1).getTime(),
},
lifetimes: {
attached() {
this.setData({
maxDate: new Date().getTime(),
currentDate: new Date().getTime(),
})
}
},
/**
* 组件的方法列表
*/
methods: {
onCancel() {
this.triggerEvent("cancel")
},
onConfirm(e) {
this.triggerEvent("confirm", { time: dayjs(e.detail).format("YYYY-MM-DD HH:mm:ss") })
}
}
})