diff --git a/document/components/docs/en-US/index-list.md b/document/components/docs/en-US/index-list.md index ba6af1c9f81c4beaa4e9299413f90395e022c9db..62e9b1c4b39270f65099e834ccf851c2fdc5be5f 100644 --- a/document/components/docs/en-US/index-list.md +++ b/document/components/docs/en-US/index-list.md @@ -131,6 +131,98 @@ color: #ffcd32 ``` +- Pull Up Load + + Beside, you could use `pullUpLoad` to enable pull-up-load, the detail config is same as the `options.pullUpLoad` of Scroll. + + ```html + + + ``` + ```javascript + export default { + data() { + return { + title: 'Current City: BEIJING', + data: cityData.slice(0, 4) + } + }, + methods: { + selectItem(item) { + console.log(item.name) + }, + clickTitle(title) { + console.log(title) + }, + onPullingUp() { + // Mock async load. + setTimeout(() => { + const length = this.data.length + if (length < cityData.length) { + // Update data. + this.data.push(cityData[length]) + } + // Call forceUpdate after finishing data load. + this.$refs.indexList.forceUpdate() + }, 1000) + } + } + } + ``` + + - Pull Down Refresh + + Beside, you could use `pullDownRefresh` to enable pull-down-refresh, the detail config is same as the `options.pullDownRefresh` of Scroll. + + ```html + + + ``` + ```javascript + export default { + data() { + return { + title: 'Current City: BEIJING', + data: cityData, + pullDownRefresh: { + stop: 55 + } + } + }, + methods: { + selectItem(item) { + console.log(item.name) + }, + clickTitle(title) { + console.log(title) + }, + onPullingDown() { + // Mock async load. + setTimeout(() => { + // Update data. + this.data[1].items.push(...cityData[1].items) + // Call forceUpdate after finishing data load. + this.$refs.indexList.forceUpdate() + }, 1000) + } + } + } + ``` + ### Props configuration | Attribute | Description | Type | Default | @@ -139,6 +231,8 @@ | data | data to be displayed | Array | [] | | navbar | whether need navbar | Boolean | true | | speed | when click the navigator, the transition time of scrolling to the specific anchor (unit: ms). | number | 0 | +| pullUpLoad1.8.0+ | pull-up-load, the detail config is same as the `options.pullUpLoad` of Scroll | Boolean/Object | false | +| pullDownRefresh1.8.0+ | pull-down-refresh, the detail config is same as the `options.pullDownRefresh` of Scroll | Boolean/Object | false | - `data` sub configuration @@ -157,3 +251,5 @@ Each item of `items` array must be an object that must contains the `name` attri | - | - | - | | select | triggers when clicking one of the items in IndexList | data of the item | | title-click | triggers when clicking title(valid only if title has been configured) | the value of title | +| pulling-up1.8.0+ | triggers when the distance of pulling up exceeds the threshold, if pullUpLoad is true | - | +| pulling-down1.8.0+ | triggers when the distance of pulling down exceeds the threshold, if pullDownRefresh is true | - | diff --git a/document/components/docs/en-US/scroll.md b/document/components/docs/en-US/scroll.md index 211bc5148d613036aed294995230efc039adef79..a6516557e716b97ea8cd2ab717d244037060f0f2 100644 --- a/document/components/docs/en-US/scroll.md +++ b/document/components/docs/en-US/scroll.md @@ -68,13 +68,13 @@ }, methods: { onPullingDown() { - // 模拟更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. this.items.unshift('I am new data: ' + +new Date()) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) @@ -113,10 +113,10 @@ }, methods: { onPullingUp() { - // 更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. let newPage = [ 'I am line ' + ++this.itemIndex, 'I am line ' + ++this.itemIndex, @@ -127,7 +127,7 @@ this.items = this.items.concat(newPage) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) diff --git a/document/components/docs/zh-CN/index-list.md b/document/components/docs/zh-CN/index-list.md index eb189ff64b4b86af53e8b5fc92f6a7f45f5ab2be..8a209c9eef842b21bef46f2ae6c77185acba4e4e 100644 --- a/document/components/docs/zh-CN/index-list.md +++ b/document/components/docs/zh-CN/index-list.md @@ -131,6 +131,98 @@ color: #ffcd32 ``` +- 上拉加载 + + 可以通过 `pullUpLoad` 属性开启上拉加载功能,具体配置同 Scroll 组件的 `options.pullUpLoad`。 + + ```html + + + ``` + ```javascript + export default { + data() { + return { + title: 'Current City: BEIJING', + data: cityData.slice(0, 4) + } + }, + methods: { + selectItem(item) { + console.log(item.name) + }, + clickTitle(title) { + console.log(title) + }, + onPullingUp() { + // Mock async load. + setTimeout(() => { + const length = this.data.length + if (length < cityData.length) { + // Update data. + this.data.push(cityData[length]) + } + // Call forceUpdate after finishing data load. + this.$refs.indexList.forceUpdate() + }, 1000) + } + } + } + ``` + + - 下拉刷新 + + 可以通过 `pullDownRefresh` 属性开启下拉刷新功能,具体配置同 Scroll 组件的 `options.pullDownRefresh`。 + + ```html + + + ``` + ```javascript + export default { + data() { + return { + title: 'Current City: BEIJING', + data: cityData, + pullDownRefresh: { + stop: 55 + } + } + }, + methods: { + selectItem(item) { + console.log(item.name) + }, + clickTitle(title) { + console.log(title) + }, + onPullingDown() { + // Mock async load. + setTimeout(() => { + // Update data. + this.data[1].items.push(...cityData[1].items) + // Call forceUpdate after finishing data load. + this.$refs.indexList.forceUpdate() + }, 1000) + } + } + } + ``` + ### Props 配置 | 参数 | 说明 | 类型 | 默认值 | @@ -139,6 +231,8 @@ | data | 需要展示的数据 | Array | [] | | navbar | 是否需要导航栏 | Boolean | true | | speed | 点击导航栏索引时,滚动到相应位置的动画时间(单位:ms) | number | 0 | +| pullUpLoad1.8.0+ | 上拉加载,具体配置参考 scroll 组件的 `options.pullUpLoad` | Boolean/Object | false | +| pullDownRefresh1.8.0+ | 下拉刷新,具体配置参考 scroll 组件的 `options.pullDownRefresh` | Boolean/Object | false | - `data` 子配置项 @@ -157,3 +251,5 @@ | - | - | - | | select | 点击 IndexList 的某一项后触发 | 该选项的数据 | | title-click | 点击 title 后触发(title 必须设置后才有效) | title属性值 | +| pulling-up1.8.0+ | 当 pullUpLoad 属性为 true 时,在上拉超过阈值时触发 | - | +| pulling-down1.8.0+ | 当 pullDownRefresh 属性为 true 时,在下拉超过阈值时触发 | - | diff --git a/document/components/docs/zh-CN/scroll.md b/document/components/docs/zh-CN/scroll.md index 3464fc7fd0886c9aa83fca5fa55bf94d184cdd8b..e3d27a57042f8e2e270007ed54b522723656b692 100644 --- a/document/components/docs/zh-CN/scroll.md +++ b/document/components/docs/zh-CN/scroll.md @@ -83,13 +83,13 @@ }, methods: { onPullingDown() { - // 模拟更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. this.items.unshift('I am new data: ' + +new Date()) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) @@ -130,10 +130,10 @@ }, methods: { onPullingUp() { - // 更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. let newPage = [ 'I am line ' + ++this.itemIndex, 'I am line ' + ++this.itemIndex, @@ -144,7 +144,7 @@ this.items = this.items.concat(newPage) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) diff --git a/example/pages/index-list/index-list.vue b/example/pages/index-list/index.vue similarity index 83% rename from example/pages/index-list/index-list.vue rename to example/pages/index-list/index.vue index e6c8fd02c6a2f9adf297156b6e53c7bc4eec82aa..a347e2a84c975eaea13c7097c6bd4a03891fd4f0 100644 --- a/example/pages/index-list/index-list.vue +++ b/example/pages/index-list/index.vue @@ -4,6 +4,8 @@ Default Custom + Pull Up Load + Pull Down Refresh diff --git a/example/pages/index-list/pull-down-refresh.vue b/example/pages/index-list/pull-down-refresh.vue new file mode 100644 index 0000000000000000000000000000000000000000..d2d73dbb9b5fbb7d11a89d675a9c86908f582ec5 --- /dev/null +++ b/example/pages/index-list/pull-down-refresh.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/example/pages/index-list/pull-up-load.vue b/example/pages/index-list/pull-up-load.vue new file mode 100644 index 0000000000000000000000000000000000000000..c41bb0be52a34b320f9fa265751aabf88c4414c5 --- /dev/null +++ b/example/pages/index-list/pull-up-load.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/example/pages/scroll.vue b/example/pages/scroll.vue index c6d3d91cbcb0b8c5414fba3047bc5fca0afe0be3..45e7fe040d7dfe7a24a5a1e397d6f65a40b60a21 100644 --- a/example/pages/scroll.vue +++ b/example/pages/scroll.vue @@ -233,22 +233,22 @@ }, methods: { onPullingDown() { - // 模拟更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. this.items.unshift(this.customList ? _foods[1] : `I am new data: ${+new Date()}`) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) }, onPullingUp() { - // 更新数据 + // Mock async load. setTimeout(() => { if (Math.random() > 0.5) { - // 如果有新数据 + // If have new data, just update the data property. let newPage = this.customList ? _foods.slice(0, 5) : [ 'I am line ' + ++this.itemIndex, 'I am line ' + ++this.itemIndex, @@ -259,7 +259,7 @@ this.items = this.items.concat(newPage) } else { - // 如果没有新数据 + // If no new data, you need use the method forceUpdate to tell us the load is done. this.$refs.scroll.forceUpdate() } }, 1000) diff --git a/example/router/routes.js b/example/router/routes.js index 4dc3e41a7f35d879084f01481d44d481bae3dcc9..5b6bdf7563b888a1b5912a1f801ba4f24757243b 100644 --- a/example/router/routes.js +++ b/example/router/routes.js @@ -22,9 +22,11 @@ import Select from '../pages/select.vue' import Dialog from '../pages/dialog.vue' import ActionSheet from '../pages/action-sheet.vue' import Scroll from '../pages/scroll.vue' -import IndexList from '../pages/index-list/index-list.vue' +import IndexList from '../pages/index-list/index.vue' import IndexListDefault from '../pages/index-list/default.vue' import IndexListCustom from '../pages/index-list/custom.vue' +import IndexListPullUpLoad from '../pages/index-list/pull-up-load.vue' +import IndexListPullDownRefresh from '../pages/index-list/pull-down-refresh.vue' import Upload from '../pages/upload.vue' import Validator from '../pages/validator.vue' import Swipe from '../pages/swipe/index.vue' @@ -147,6 +149,14 @@ const routes = [ { path: 'custom', component: IndexListCustom + }, + { + path: 'pull-up-load', + component: IndexListPullUpLoad + }, + { + path: 'pull-down-refresh', + component: IndexListPullDownRefresh } ] }, diff --git a/src/components/index-list/index-list.vue b/src/components/index-list/index-list.vue index 2be17633adf25aaa1ab98e462938bfb19160429d..0d07bf829f33ae5f04e73179f515c5bcd28dc781 100644 --- a/src/components/index-list/index-list.vue +++ b/src/components/index-list/index-list.vue @@ -1,11 +1,13 @@