ant-design-vue/components/calendar/demo/select.vue

49 lines
962 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<docs>
---
order: 3
title:
zh-CN: 选择功能
en-US: Selectable Calendar
---
## zh-CN
一个通用的日历面板支持年/月切换
## en-US
A basic calendar component with Year/Month switch.
</docs>
<template>
<a-alert :message="`You selected date: ${selectedValue && selectedValue.format('YYYY-MM-DD')}`" />
<a-calendar :value="date" @select="onSelect" @panelChange="onPanelChange" />
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import dayjs, { Dayjs } from 'dayjs';
export default defineComponent({
setup() {
const date = ref(dayjs('2017-01-25'));
const selectedValue = ref(dayjs('2017-01-25'));
const onSelect = (value: Dayjs) => {
date.value = value;
selectedValue.value = value;
};
const onPanelChange = (value: Dayjs) => {
date.value = value;
};
return {
date,
selectedValue,
onSelect,
onPanelChange,
};
},
});
</script>