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

47 lines
937 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>
<tiny-button @click="fn" type="primary"> 时间选择器组件 </tiny-button>
<p>{{ value }}</p>
<p>格式化值{{ formatValue }}</p>
<tiny-time-picker-mobile
v-model="value"
title="日期选择"
:visible="boxVisibility"
@update:visible="boxVisibility = $event"
>
</tiny-time-picker-mobile>
</div>
</template>
<script>
import { TimePickerMobile, Button } from '@opentiny/vue'
export default {
components: {
TinyTimePickerMobile: TimePickerMobile,
TinyButton: Button
},
data() {
return {
value: [2, 33, 20],
boxVisibility: false
}
},
computed: {
formatValue() {
if (!this.value) return ''
return this.value.map((item) => this.addZero(item)).join(':')
}
},
methods: {
addZero(time) {
return ('0' + time).slice(-2)
},
fn() {
this.boxVisibility = true
}
}
}
</script>