mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 18:00:27 +08:00
feat(Calendar): add select event
This commit is contained in:
parent
43a0aed8c9
commit
c447152be9
@ -24,17 +24,21 @@ Vue.use(Calendar);
|
|||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| v-model | 选中的日期 | `Date` | - | - |
|
| v-model | 选中的日期 | `Date` | - | - |
|
||||||
|
| type | 选择类型,`single`为选择单日,`range`为选择日期区间 | `string` | `single` | - |
|
||||||
| title | 日历标题 | `string` | - | - |
|
| title | 日历标题 | `string` | - | - |
|
||||||
|
| min-date | 最小日期 | `Date` | 当前时间 | - |
|
||||||
|
| max-date | 最大日期 | `Date` | 当前时间的六个月后 | - |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
|
| select | 选择日期时触发 | value: Date |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
| 名称 | 说明 | SlotProps |
|
| 名称 | 说明 |
|
||||||
|------|------|------|
|
|------|------|
|
||||||
|
|
||||||
### 方法
|
### 方法
|
||||||
|
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
<demo-block :title="$t('basicUsage')">
|
<demo-block :title="$t('basicUsage')">
|
||||||
<van-cell
|
<van-cell
|
||||||
:title="$t('selectDate')"
|
:title="$t('selectDate')"
|
||||||
|
:value="formatDate(date.selectDate)"
|
||||||
is-link
|
is-link
|
||||||
@click="toggle('selectDate', true)"
|
@click="toggle('selectDate', true)"
|
||||||
/>
|
/>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<van-popup
|
<van-popup v-model="show.selectDate" round closeable position="bottom">
|
||||||
v-model="show.selectDate"
|
<van-calendar
|
||||||
round
|
v-model="date.selectDate"
|
||||||
closeable
|
:title="$t('title')"
|
||||||
position="bottom"
|
@select="show.selectDate = false"
|
||||||
>
|
/>
|
||||||
<van-calendar v-model="date.selectDate" :title="$t('title')" />
|
|
||||||
</van-popup>
|
</van-popup>
|
||||||
</demo-section>
|
</demo-section>
|
||||||
</template>
|
</template>
|
||||||
@ -46,6 +46,12 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
toggle(type, show) {
|
toggle(type, show) {
|
||||||
this.show[type] = show;
|
this.show[type] = show;
|
||||||
|
},
|
||||||
|
|
||||||
|
formatDate(date) {
|
||||||
|
if (date) {
|
||||||
|
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -172,6 +172,7 @@ export default createComponent({
|
|||||||
|
|
||||||
if (this.type === 'single') {
|
if (this.type === 'single') {
|
||||||
this.$emit('input', item.date);
|
this.$emit('input', item.date);
|
||||||
|
this.$emit('select', item.date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -76,9 +76,11 @@
|
|||||||
width: 14.285%;
|
width: 14.285%;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
font-size: @font-size-lg;
|
font-size: @font-size-lg;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
&--disabled {
|
&--disabled {
|
||||||
color: @gray-5;
|
color: @gray-5;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user