From e53f5436390241a46b07b01fff472171d5fb47fd Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 7 Feb 2018 17:09:09 +0800 Subject: [PATCH] [new feature] Picker: add loading prop (#619) --- docs/demos/views/picker.vue | 4 ++++ docs/markdown/en-US/area.md | 1 + docs/markdown/en-US/picker.md | 8 ++++++++ docs/markdown/zh-CN/area.md | 1 + docs/markdown/zh-CN/picker.md | 8 ++++++++ packages/area/index.vue | 2 ++ packages/picker/PickerColumn.vue | 5 +---- packages/picker/index.vue | 17 +++++++++++++++-- packages/vant-css/src/loading.css | 4 ++-- packages/vant-css/src/picker.css | 18 +++++++++++++++++- 10 files changed, 59 insertions(+), 9 deletions(-) diff --git a/docs/demos/views/picker.vue b/docs/demos/views/picker.vue index 9e752f784..d06ee9a5f 100644 --- a/docs/demos/views/picker.vue +++ b/docs/demos/views/picker.vue @@ -21,6 +21,10 @@ + + + + diff --git a/docs/markdown/en-US/area.md b/docs/markdown/en-US/area.md index 4127c6f78..b5bc71659 100644 --- a/docs/markdown/en-US/area.md +++ b/docs/markdown/en-US/area.md @@ -45,6 +45,7 @@ Set `columns-num` with 2, you'll have a 2 level picker. | area-list | an object contains these properties: `province_list`, `city_list` and `county_list` | `Object` | - | - | | columns-num | level of picker | `String`,`Number` | 3 | - | | item-height | Option height | `Number` | `44` | - | +| loading | Whether to show loading prompt | `Boolean` | `false` | - | | visible-item-count | Count of visible columns | `Number` | `5` | - | ### Event diff --git a/docs/markdown/en-US/picker.md b/docs/markdown/en-US/picker.md index 955fdf310..bbe7ed490 100644 --- a/docs/markdown/en-US/picker.md +++ b/docs/markdown/en-US/picker.md @@ -114,6 +114,13 @@ export default { }; ``` +#### Loading +When Picker columns data is acquired asynchronously, use `loading` prop to show loading prompt + +```html + +``` + ### API | Attribute | Description | Type | Default | Accepted Values | @@ -121,6 +128,7 @@ export default { | columns | Columns data | `Array` | `[]` | - | | show-toolbar | Whether to show toolbar | `Boolean` | `false` | - | | title | Toolbar title | `String` | `''` | - | +| loading | Whether to show loading prompt | `Boolean` | `false` | - | | confirm-button-text | Text of confirm button | `String` | `Confirm` | - | | cancel-button-text | Text of cancel button | `String` | `Cancel` | - | | item-height | Option height | `Number` | `44` | - | diff --git a/docs/markdown/zh-CN/area.md b/docs/markdown/zh-CN/area.md index 27ca37f72..5ceeaa222 100644 --- a/docs/markdown/zh-CN/area.md +++ b/docs/markdown/zh-CN/area.md @@ -42,6 +42,7 @@ Vue.use(Area); | title | 顶部栏标题 | `String` | `''` | - | | area-list | 省市县数据,格式见下方 | `Object` | - | - | | columns-num | 省市县显示列数,3-省市县,2-省市,1-省 | `String`,`Number` | `3` | - | +| loading | 是否显示加载状态 | `Boolean` | `false` | - | | item-height | 选项高度 | `Number` | `44` | - | | visible-item-count | 可见的选项个数 | `Number` | `5` | - | diff --git a/docs/markdown/zh-CN/picker.md b/docs/markdown/zh-CN/picker.md index 9cc425dce..85ba482ec 100644 --- a/docs/markdown/zh-CN/picker.md +++ b/docs/markdown/zh-CN/picker.md @@ -116,6 +116,13 @@ export default { }; ``` +#### 加载状态 +当 Picker 数据是通过异步获取时,可以通过 `loading` 属性显示加载提示 + +```html + +``` + ### API | 参数 | 说明 | 类型 | 默认值 | 可选值 | @@ -123,6 +130,7 @@ export default { | columns | 对象数组,配置每一列显示的数据 | `Array` | `[]` | - | | show-toolbar | 是否显示顶部栏 | `Boolean` | `false` | - | | title | 顶部栏标题 | `String` | `''` | - | +| loading | 是否显示加载状态 | `Boolean` | `false` | - | | confirm-button-text | 确认按钮文字 | `String` | `完成` | - | | cancel-button-text | 取消按钮文字 | `String` | `取消` | - | | item-height | 选项高度 | `Number` | `44` | - | diff --git a/packages/area/index.vue b/packages/area/index.vue index 1d4e4871b..5a85a7b17 100644 --- a/packages/area/index.vue +++ b/packages/area/index.vue @@ -5,6 +5,7 @@ show-toolbar value-key="name" :title="title" + :loading="loading" :columns="columns" :item-height="itemHeight" :visible-item-count="visibleItemCount" @@ -28,6 +29,7 @@ export default create({ props: { value: {}, title: String, + loading: Boolean, areaList: Object, itemHeight: Number, visibleItemCount: Number, diff --git a/packages/picker/PickerColumn.vue b/packages/picker/PickerColumn.vue index 97e6da7e1..3ea162359 100644 --- a/packages/picker/PickerColumn.vue +++ b/packages/picker/PickerColumn.vue @@ -37,14 +37,11 @@ export default create({ valueKey: String, className: String, itemHeight: Number, + visibleItemCount: Number, options: { type: Array, default: () => [] }, - visibleItemCount: { - type: Number, - default: 5 - }, defaultIndex: { type: Number, default: 0 diff --git a/packages/picker/index.vue b/packages/picker/index.vue index 8bd363980..faecea353 100644 --- a/packages/picker/index.vue +++ b/packages/picker/index.vue @@ -7,7 +7,10 @@
{{ confirmButtonText || $t('confirm') }}
-
+
+ +
+