feat(Calendar): add position prop

This commit is contained in:
陈嘉涵 2019-12-28 11:43:55 +08:00 committed by neverland
parent 8dea26db95
commit 956800b95c
4 changed files with 12 additions and 3 deletions

View File

@ -196,6 +196,7 @@ Set `poppable` to `false`, the calendar will be displayed directly on the page i
| default-date | Default selected date | *Date \| Date[]* | Today | - | | default-date | Default selected date | *Date \| Date[]* | Today | - |
| row-height | Row height | *number* | `64` | - | | row-height | Row height | *number* | `64` | - |
| formatter | Day formatter | *(day: Day) => Day* | - | - | | formatter | Day formatter | *(day: Day) => Day* | - | - |
| position | Popup position, can be set to `top` `right` `left` | *string* | `bottom` | - |
| poppable | Whether to show the calendar inside a popup | *boolean* | `true` | - | | poppable | Whether to show the calendar inside a popup | *boolean* | `true` | - |
| show-mark | Whether to show background month mark | *boolean* | `true` | - | | show-mark | Whether to show background month mark | *boolean* | `true` | - |
| show-confirm | Whether to show confirm button | *boolean* | `true` | - | | show-confirm | Whether to show confirm button | *boolean* | `true` | - |

View File

@ -196,6 +196,7 @@ export default {
| default-date | 默认选中的日期 | *Date \| Date[]* | 今天 | - | | default-date | 默认选中的日期 | *Date \| Date[]* | 今天 | - |
| row-height | 日期行高 | *number* | `64` | - | | row-height | 日期行高 | *number* | `64` | - |
| formatter | 日期格式化函数 | *(day: Day) => Day* | - | - | | formatter | 日期格式化函数 | *(day: Day) => Day* | - | - |
| position | 弹出位置,可选值为 `top` `right` `left` | *string* | `bottom` | - |
| poppable | 是否以弹层的形式展示日历 | *boolean* | `true` | - | | poppable | 是否以弹层的形式展示日历 | *boolean* | `true` | - |
| show-mark | 是否显示月份背景水印 | *boolean* | `true` | - | | show-mark | 是否显示月份背景水印 | *boolean* | `true` | - |
| show-confirm | 是否展示确认按钮 | *boolean* | `true` | - | | show-confirm | 是否展示确认按钮 | *boolean* | `true` | - |

View File

@ -41,6 +41,10 @@ export default createComponent({
return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()); return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
} }
}, },
position: {
type: String,
default: 'bottom'
},
rowHeight: { rowHeight: {
type: Number, type: Number,
default: ROW_HEIGHT default: ROW_HEIGHT
@ -307,9 +311,9 @@ export default createComponent({
<Popup <Popup
round round
closeable closeable
value={this.value}
position="bottom"
class={bem('popup')} class={bem('popup')}
value={this.value}
position={this.position}
onInput={this.togglePopup} onInput={this.togglePopup}
> >
{this.genCalendar()} {this.genCalendar()}

View File

@ -7,7 +7,10 @@
background-color: @calendar-background-color; background-color: @calendar-background-color;
&__popup { &__popup {
height: @calendar-popup-height; &.van-popup--top,
&.van-popup--bottom {
height: @calendar-popup-height;
}
.van-popup__close-icon { .van-popup__close-icon {
top: 13px; top: 13px;