tiny-vue/examples/sites/demos/mobile-first/app/date-picker-mobile/year-month-disabled.vue

53 lines
1.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="demo-date-picker-mobile-container">
<tiny-button @click="fn" type="primary"> 年月选择器 </tiny-button>
<p>{{ value }}</p>
<p>格式化值{{ formatValue }}</p>
<tiny-date-picker-mobile
v-model="value"
title="年月选择"
:picker-options="pickerOptions"
type="year-month-range"
:visible="boxVisibility"
@update:visible="boxVisibility = $event"
>
</tiny-date-picker-mobile>
</div>
</template>
<script>
import { DatePickerMobileFirst, Button } from '@opentiny/vue'
export default {
components: {
TinyDatePickerMobile: DatePickerMobileFirst,
TinyButton: Button
},
data() {
return {
value: ['2022-11', '2023-1'],
boxVisibility: false,
pickerOptions: {
disabledDate: (date) => {
return date.getTime() > Date.now() || date.getTime() < new Date('2020/3/1').getTime()
}
}
}
},
computed: {
formatValue() {
if (!this.value || this.value.length === 0) return ''
const date1 = new Date(this.value[0])
const date2 = new Date(this.value[1])
return `[${date1.getFullYear()}/${date1.getMonth() + 1}, ${date2.getFullYear()}/${date2.getMonth() + 1}]`
}
},
methods: {
fn() {
this.boxVisibility = true
}
}
}
</script>