uniApp 简单的日期时间选择器, 可选择年, 月, 日, 时, 分
该插件遵循 easycom 规范
[JavaScript] 纯文本查看 复制代码 <template>
<view>
<button type="default" @click="openDatetimePicker">open picker</button>
<SimpleDateTimePicker
ref="myPicker"
@submit="handleSubmit"
:start-year="2000"
:end-year="2030"
/>
</view>
</template>
[JavaScript] 纯文本查看 复制代码 import SimpleDateTimePicker from "uni_modules/buuug7-simple-datetime-picker/components/buuug7-simple-datetime-picker/buuug7-simple-datetime-picker.vue";
export default {
components: {
SimpleDateTimePicker,
},
data() {
return {
birthday: "",
};
},
methods: {
// 打开picker
openDatetimePicker() {
this.$refs.myPicker.show();
},
// 关闭picker
closeDatetimePicker() {
this.$refs.myPicker.hide();
},
handleSubmit(e) {
// {year: "2019", month: "07", day: "17", hour: "15", minute: "21"}
console.log(e);
this.birthday = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`;
},
},
};
插件市场地址: https://ext.dcloud.net.cn/plugin?id=592
|