tiny-vue/examples/sites/demos/mobile-first/app/date-picker-mobile/basic-usage.vue

45 lines
967 B
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="日期选择"
: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: '',
boxVisibility: false
}
},
computed: {
formatValue() {
if (!this.value) return ''
const date = new Date(this.value)
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
}
},
methods: {
fn() {
this.boxVisibility = true
}
}
}
</script>