본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Calendar

원문 보기 위키 갱신

Calendar (달력)

날짜 형태의 데이터를 달력 모양으로 보여주는 컨테이너예요.

출처: 문서

본문

언제 사용하나요 (When To Use)

일정, 시간표, 가격 달력, 음력 달력처럼 데이터가 날짜 형태일 때 써요. 이 컴포넌트는 연/월 전환도 지원해요.

API

참고: Calendar 로케일(지역 설정) 중 일부는 value에서 읽어와요. 그래서 dayjs의 로케일을 올바르게 설정해 주세요.

// The default locale is en-US, if you want to use other locale, just set locale in entry file globally.
// import dayjs from 'dayjs';
// import 'dayjs/locale/zh-cn';
// dayjs.locale('zh-cn');

<a-calendar v-model:value @panelChange="onPanelChange" @select="onSelect"></a-calendar>

scoped slot을 지정해 진행 점(progress dot)을 커스터마이즈할 수 있어요.

속성 설명 타입 기본값 버전
dateCellRender scoped slot을 지정해 날짜 셀 표시를 커스터마이즈. 반환된 내용은 셀에 추가돼요 v-slot:dateCellRender="{current: dayjs}" -
dateFullCellRender scoped slot을 지정해 날짜 셀 표시를 커스터마이즈. 반환된 내용이 셀을 덮어써요 v-slot:dateFullCellRender="{current: dayjs}" -
disabledDate 선택할 수 없는 날짜를 지정하는 함수 (currentDate: dayjs) => boolean -
fullscreen 전체 화면으로 표시할지 여부 boolean true
headerRender 패널에 커스텀 헤더를 렌더링 v-slot:headerRender="{value: dayjs, type: string, onChange: f(), onTypeChange: f()}" - 1.5.0
locale 달력의 로케일 object default
mode 달력의 표시 모드 month | year month
monthCellRender scoped slot을 지정해 월 셀 표시를 커스터마이즈. 반환된 내용은 셀에 추가돼요 v-slot:monthCellRender="{current: dayjs}" -
monthFullCellRender scoped slot을 지정해 월 셀 표시를 커스터마이즈. 반환된 내용이 셀을 덮어써요 v-slot:monthFullCellRender="{current: dayjs}" -
validRange 유효 범위를 설정 [dayjs, dayjs] -
value(v-model) 현재 선택된 날짜 dayjs current date
valueFormat 선택 사항. 바인딩 값의 형식. 지정하지 않으면 바인딩 값은 Date 객체 string, date formats -

이벤트 (events)

이벤트 이름 설명 인자 버전
change 값이 변경될 때 호출되는 콜백 function(date: dayjs | string) -
panelChange 패널이 변경될 때 호출되는 콜백 function(date: dayjs | string, mode: string) -
select 날짜가 선택될 때 호출되는 콜백. 출처 정보 포함 function(date: dayjs | string,info:{ source: 'year' | 'month' | 'date' | 'customize' }) -

패널 클릭에서 날짜를 어떻게 얻나요? (How to get date from panel click?)

select 이벤트가 info.source를 제공해 이 문제를 도와줘요.

<script lang="ts" setup>
  const onSelect = (date, { source }) => {
    if (source === 'date') {
      console.log('Panel Select:', source);
    }
  };
</script>
<template>
  <a-calendar @select="onSelect" />
</template>

더 알아보기 (Learn more)