小程式日期時間選擇器

2021-10-25 01:41:12 字數 1875 閱讀 2183

從底部彈起的滾動選擇器。型別有普通選擇器 、 多列選擇器 、 時間選擇器 、日期選擇器 、 省市區選擇器。

沒有現成的時間和日期合併在一起的,從demo裡面可以看到 可以用多列選擇器來實現。

const date = new date();

const years = ;

const months = ;

const days = ;

const hours = ;

const minutes = ;

//獲取年

for (let i = 2018; i <= date.getfullyear() + 5; i++)

//獲取月份

for (let i = 1; i <= 12; i++)

months.push("" + i);

}//獲取日期

for (let i = 1; i <= 31; i++)

days.push("" + i);

}//獲取小時

for (let i = 0; i < 24; i++)

hours.push("" + i);

}//獲取分鐘

for (let i = 0; i < 60; i++)

minutes.push("" + i);

}page(,

onload: function() )

},//獲取時間日期

bindmultipickerchange: function(e) )

const index = this.data.multiindex;

const year = this.data.multiarray[0][index[0]];

const month = this.data.multiarray[1][index[1]];

const day = this.data.multiarray[2][index[2]];

const hour = this.data.multiarray[3][index[3]];

const minute = this.data.multiarray[4][index[4]];

// console.log(`$-$-$-$-$`);

this.setdata()

// console.log(this.data.time);

},//監聽picker的滾動事件

bindmultipickercolumnchange: function(e) )

} '修改的列為', e.detail.column, ',值為', e.detail.value);

if (e.detail.column == 1)

temp.push("" + i);

}this.setdata();

} else if (num == 4 || num == 6 || num == 9 || num == 11)

temp.push("" + i);

}this.setdata();

} else if (num == 2)

temp.push("" + i);

}this.setdata();

} else

temp.push("" + i);

}this.setdata();}}

console.log(this.data.multiarray[2]);

} var data = ;

data.multiindex[e.detail.column] = e.detail.value;

this.setdata(data);

},})

小程式 日期時間選擇器 精確到秒

提供三種模式 date yyyy mm dd time hh mm ss datetime yyyy mm dd hh mm ss 上圖 引數引數 說明型別 預設值mode 選擇器型別 string date disabled 是否禁用 boolean false placeholder 輸入框提示...

JS日期時間選擇器

本文介紹一種日期和時間選擇器的用法。此選擇器由jqueryui實現,支援精確到毫秒的時間選擇。此選擇器專案位址為 demo位址為 效果圖另外關於js時間選擇器還可以參考其他專案 此控制項使用非常簡單,只需要引入js和css,然後在加上一句jquery 即可。除了引入jquery ui的樣式外,還需額...

時間,日期選擇器

timepicker 時間選擇器 方法描述 integer getcurrenthour 返回當前設定的小時 integer getcurrentminute 返回當前設定的分鐘 boolean is24hourview 判斷是否是24小時制 void setcurrenthour integer ...