From 01c7409e6e003be4d8aa950359a472c2ebacaf47 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 26 Jul 2020 13:18:25 +0800 Subject: [PATCH] feat: migrate List component --- breaking-changes.md | 1 + components.js | 1 + src/list/README.md | 12 ++++++------ src/list/README.zh-CN.md | 12 ++++++------ src/list/demo/index.vue | 13 ++++++++----- src/list/index.js | 23 +++++++++++++---------- vant.config.js | 16 ++++++++-------- 7 files changed, 43 insertions(+), 35 deletions(-) diff --git a/breaking-changes.md b/breaking-changes.md index db65ca1f6..e55b7c0d5 100644 --- a/breaking-changes.md +++ b/breaking-changes.md @@ -8,6 +8,7 @@ - Popup: `v-model` 重命名为 `v-model:show` - ShareSheet: `v-model` 重命名为 `v-model:show` - ActionSheet: `v-model` 重命名为 `v-model:show` +- List: `v-model` 重命名为 `v-model:loading`,`error.sync` 重命名为 `v-model:error` - Field: v-model 对应的属性 `value` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue` - Switch: v-model 对应的属性 `value` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue` - Sidebar: v-model 对应的属性 `activeKey` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue` diff --git a/components.js b/components.js index 7117b4908..87557aa4c 100644 --- a/components.js +++ b/components.js @@ -39,4 +39,5 @@ module.exports = [ 'field', 'tabbar', 'tabbar-item', + 'list', ]; diff --git a/src/list/README.md b/src/list/README.md index b2b0f31a5..49c307ca5 100644 --- a/src/list/README.md +++ b/src/list/README.md @@ -19,7 +19,7 @@ Vue.use(List); ```html @@ -89,9 +89,9 @@ export default { ### PullRefresh ```html - + @@ -100,9 +100,9 @@ export default { List 组件可以与 [PullRefresh](#/zh-CN/pull-refresh) 组件结合使用,实现下拉刷新的效果 ```html - + 触发`load`事件,必须使用`sync`修饰符 | _boolean_ | `false` | | offset | 滚动条与底部距离小于 offset 时触发`load`事件 | _number \| string_ | `300` | diff --git a/src/list/demo/index.vue b/src/list/demo/index.vue index 0d956b81f..ac9758e0e 100644 --- a/src/list/demo/index.vue +++ b/src/list/demo/index.vue @@ -3,7 +3,7 @@ @@ -25,9 +25,12 @@ - + - {this.slots('loading') || ( + {this.$slots.loading ? ( + this.$slots.loading() + ) : ( {this.loadingText || t('loading')} )} @@ -132,7 +132,9 @@ export default createComponent({ genFinishedText() { if (this.finished) { - const text = this.slots('finished') || this.finishedText; + const text = this.$slots.finished + ? this.$slots.finished() + : this.finishedText; if (text) { return
{text}
; @@ -142,7 +144,7 @@ export default createComponent({ genErrorText() { if (this.error) { - const text = this.slots('error') || this.errorText; + const text = this.$slots.error ? this.$slots.error() : this.errorText; if (text) { return ( @@ -157,14 +159,15 @@ export default createComponent({ render() { const Placeholder =
; + const Content = this.$slots.default?.(); return (
- {this.direction === 'down' ? this.slots() : Placeholder} + {this.direction === 'down' ? Content : Placeholder} {this.genLoading()} {this.genFinishedText()} {this.genErrorText()} - {this.direction === 'up' ? this.slots() : Placeholder} + {this.direction === 'up' ? Content : Placeholder}
); }, diff --git a/vant.config.js b/vant.config.js index 05fae893a..6e159f079 100644 --- a/vant.config.js +++ b/vant.config.js @@ -249,10 +249,10 @@ module.exports = { // path: 'lazyload', // title: 'Lazyload 懒加载', // }, - // { - // path: 'list', - // title: 'List 列表', - // }, + { + path: 'list', + title: 'List 列表', + }, { path: 'notice-bar', title: 'NoticeBar 通知栏', @@ -583,10 +583,10 @@ module.exports = { // path: 'lazyload', // title: 'Lazyload', // }, - // { - // path: 'list', - // title: 'List', - // }, + { + path: 'list', + title: 'List', + }, { path: 'notice-bar', title: 'NoticeBar',