mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
feat(Calendar): add cancel event (#2990)
* feat(Calendar): add cancel event * feat(Calendar): rename cancel event
This commit is contained in:
parent
0bad228027
commit
a6f2d4e668
@ -48,6 +48,10 @@ Page({
|
||||
console.log(event);
|
||||
},
|
||||
|
||||
onUnselect(event) {
|
||||
console.log(event);
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.setData({ showCalendar: false });
|
||||
},
|
||||
|
@ -131,6 +131,7 @@
|
||||
confirm-disabled-text="{{ confirmDisabledText }}"
|
||||
bind:confirm="onConfirm"
|
||||
bind:select="onSelect"
|
||||
bind:unselect="onUnselect"
|
||||
bind:open="onOpen"
|
||||
bind:opened="onOpened"
|
||||
bind:close="onClose"
|
||||
|
@ -308,6 +308,7 @@ Page({
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
| ------- | ------------------------------------------------------------------ | ----------------------- |
|
||||
| select | 点击任意日期时触发 | _value: Date \| Date[]_ |
|
||||
| unselect | 当 Canlendar 的 `type` 为 `multiple` 时,点击已选中的日期时触发 | _value: Date_ |
|
||||
| confirm | 日期选择完成后触发,若`show-confirm`为`true`,则点击确认按钮后触发 | _value: Date \| Date[]_ |
|
||||
| open | 打开弹出层时触发 | - |
|
||||
| close | 关闭弹出层时触发 | - |
|
||||
|
@ -247,8 +247,9 @@ VantComponent({
|
||||
});
|
||||
|
||||
if (selected) {
|
||||
currentDate.splice(selectedIndex, 1);
|
||||
const cancelDate = currentDate.splice(selectedIndex, 1);
|
||||
this.setData({ currentDate });
|
||||
this.unselect(cancelDate);
|
||||
} else {
|
||||
this.select([...currentDate, date]);
|
||||
}
|
||||
@ -257,6 +258,13 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
|
||||
unselect(dateArray) {
|
||||
const date = dateArray[0];
|
||||
if (date) {
|
||||
this.$emit('unselect', copyDates(date));
|
||||
}
|
||||
},
|
||||
|
||||
select(date, complete) {
|
||||
const getTime = (date: Date | number) =>
|
||||
(date instanceof Date ? date.getTime() : date);
|
||||
|
Loading…
x
Reference in New Issue
Block a user