39 lines
1.0 KiB
Vue
39 lines
1.0 KiB
Vue
<script setup lang="ts">
|
||
import {
|
||
DateField,
|
||
DateFieldGroup,
|
||
DateFieldInput,
|
||
DateFieldSegment,
|
||
Label,
|
||
Description,
|
||
Button,
|
||
} from "@heroui-vue/components";
|
||
import { shallowRef } from "vue";
|
||
import {
|
||
today,
|
||
getLocalTimeZone,
|
||
type DateValue,
|
||
} from "@internationalized/date";
|
||
const value = shallowRef<DateValue | null>(null);
|
||
const todayDate = today(getLocalTimeZone());
|
||
</script>
|
||
<template>
|
||
<div class="flex flex-col gap-4">
|
||
<DateField v-model="value" class="w-[256px]" name="date">
|
||
<Label>日期</Label>
|
||
<DateFieldGroup>
|
||
<DateFieldInput v-slot="{ segment }">
|
||
<DateFieldSegment :segment="segment" />
|
||
</DateFieldInput>
|
||
</DateFieldGroup>
|
||
<Description>
|
||
当前值:{{ value ? value.toString() : "(空)" }}
|
||
</Description>
|
||
</DateField>
|
||
<div class="flex gap-2">
|
||
<Button variant="tertiary" @click="value = todayDate">设为今天</Button>
|
||
<Button variant="tertiary" @click="value = null">清空</Button>
|
||
</div>
|
||
</div>
|
||
</template>
|