From 71e2e11fde3ffa4f3b6376de3c146637928684ba Mon Sep 17 00:00:00 2001 From: Zhiqi Lin <61330648+rickylin047@users.noreply.github.com> Date: Wed, 29 Sep 2021 16:13:09 +0800 Subject: [PATCH] feat(Calendar): add readonly prop (#4529) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(Calendar): add readonly prop * feat(Calendar): add comma after the new prop * revise codes based on review opinions * fix: 调整判断顺序 Co-authored-by: nemo-shen --- packages/calendar/README.md | 1 + packages/calendar/index.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/packages/calendar/README.md b/packages/calendar/README.md index 62ff75f3..dd6f110a 100644 --- a/packages/calendar/README.md +++ b/packages/calendar/README.md @@ -283,6 +283,7 @@ Page({ | confirm-text | 确认按钮的文字 | _string_ | `确定` | | confirm-disabled-text | 确认按钮处于禁用状态时的文字 | _string_ | `确定` | | first-day-of-week | 设置周起始日 | _0~6_ | `0` | +| readonly `v1.9.1` | 是否为只读状态,只读状态下不能选择日期 | _boolean_ | `false` | ### Poppable Props diff --git a/packages/calendar/index.ts b/packages/calendar/index.ts index 398ce5bb..f735e3a5 100644 --- a/packages/calendar/index.ts +++ b/packages/calendar/index.ts @@ -125,6 +125,7 @@ VantComponent({ type: Number, value: 0, }, + readonly: Boolean, }, data: { @@ -274,6 +275,10 @@ VantComponent({ }, onClickDay(event) { + if (this.data.readonly) { + return; + } + const { date } = event.detail; const { type, currentDate, allowSameDay } = this.data;