diff --git a/src/list/README.md b/src/list/README.md index 62c124d39..7e008296c 100644 --- a/src/list/README.md +++ b/src/list/README.md @@ -132,3 +132,4 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get List instance and call instance |------|------| | default | List content | | loading | Custom loading tips | +| finished | Custom finished tips | diff --git a/src/list/README.zh-CN.md b/src/list/README.zh-CN.md index dc94d1dc5..ad0a17411 100644 --- a/src/list/README.zh-CN.md +++ b/src/list/README.zh-CN.md @@ -139,6 +139,7 @@ export default { |------|------| | default | 列表内容 | | loading | 自定义底部加载中提示 | +| finished | 自定义加载完成后的提示文案 | ## 常见问题 diff --git a/src/list/index.js b/src/list/index.js index 869499777..4280c1ba5 100644 --- a/src/list/index.js +++ b/src/list/index.js @@ -126,10 +126,12 @@ export default createComponent({ }, genFinishedText() { - if (this.finished && this.finishedText) { - return ( -
{this.finishedText}
- ); + if (this.finished) { + const text = this.slots('finished') || this.finishedText; + + if (text) { + return
{text}
; + } } }, diff --git a/src/list/test/__snapshots__/index.spec.js.snap b/src/list/test/__snapshots__/index.spec.js.snap new file mode 100644 index 000000000..c85f05283 --- /dev/null +++ b/src/list/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`finished slot 1`] = ` +
+
Custom Finished
+
+
+`; diff --git a/src/list/test/index.spec.js b/src/list/test/index.spec.js index 322f3739f..6ce9b5237 100644 --- a/src/list/test/index.spec.js +++ b/src/list/test/index.spec.js @@ -70,6 +70,19 @@ test('finished', async () => { expect(wrapper.contains('.van-list__finished-text')).toBeFalsy(); }); +test('finished slot', async () => { + const wrapper = mount(List, { + propsData: { + finished: true + }, + scopedSlots: { + finished: () => 'Custom Finished' + } + }); + + expect(wrapper).toMatchSnapshot(); +}); + test('immediate check false', async () => { const wrapper = mount(List, { propsData: {