mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +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` | - | - |
|
||||
| type | 选择类型,`single`为选择单日,`range`为选择日期区间 | `string` | `single` | - |
|
||||
| title | 日历标题 | `string` | - | - |
|
||||
| min-date | 最小日期 | `Date` | 当前时间 | - |
|
||||
| max-date | 最大日期 | `Date` | 当前时间的六个月后 | - |
|
||||
|
||||
### Events
|
||||
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
|------|------|------|
|
||||
| select | 选择日期时触发 | value: Date |
|
||||
|
||||
### Slots
|
||||
|
||||
| 名称 | 说明 | SlotProps |
|
||||
|------|------|------|
|
||||
| 名称 | 说明 |
|
||||
|------|------|
|
||||
|
||||
### 方法
|
||||
|
||||
|
@ -3,18 +3,18 @@
|
||||
<demo-block :title="$t('basicUsage')">
|
||||
<van-cell
|
||||
:title="$t('selectDate')"
|
||||
:value="formatDate(date.selectDate)"
|
||||
is-link
|
||||
@click="toggle('selectDate', true)"
|
||||
/>
|
||||
</demo-block>
|
||||
|
||||
<van-popup
|
||||
v-model="show.selectDate"
|
||||
round
|
||||
closeable
|
||||
position="bottom"
|
||||
>
|
||||
<van-calendar v-model="date.selectDate" :title="$t('title')" />
|
||||
<van-popup v-model="show.selectDate" round closeable position="bottom">
|
||||
<van-calendar
|
||||
v-model="date.selectDate"
|
||||
:title="$t('title')"
|
||||
@select="show.selectDate = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</demo-section>
|
||||
</template>
|
||||
@ -46,6 +46,12 @@ export default {
|
||||
methods: {
|
||||
toggle(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') {
|
||||
this.$emit('input', item.date);
|
||||
this.$emit('select', item.date);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -76,9 +76,11 @@
|
||||
width: 14.285%;
|
||||
height: 64px;
|
||||
font-size: @font-size-lg;
|
||||
cursor: pointer;
|
||||
|
||||
&--disabled {
|
||||
color: @gray-5;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user