mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(List): add finished slot
This commit is contained in:
parent
30b3e4b6ba
commit
8a0705d761
@ -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 |
|
||||
|
@ -139,6 +139,7 @@ export default {
|
||||
|------|------|
|
||||
| default | 列表内容 |
|
||||
| loading | 自定义底部加载中提示 |
|
||||
| finished | 自定义加载完成后的提示文案 |
|
||||
|
||||
## 常见问题
|
||||
|
||||
|
@ -126,10 +126,12 @@ export default createComponent({
|
||||
},
|
||||
|
||||
genFinishedText() {
|
||||
if (this.finished && this.finishedText) {
|
||||
return (
|
||||
<div class={bem('finished-text')}>{this.finishedText}</div>
|
||||
);
|
||||
if (this.finished) {
|
||||
const text = this.slots('finished') || this.finishedText;
|
||||
|
||||
if (text) {
|
||||
return <div class={bem('finished-text')}>{text}</div>;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
8
src/list/test/__snapshots__/index.spec.js.snap
Normal file
8
src/list/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,8 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`finished slot 1`] = `
|
||||
<div role="feed" class="van-list">
|
||||
<div class="van-list__finished-text">Custom Finished</div>
|
||||
<div class="van-list__placeholder"></div>
|
||||
</div>
|
||||
`;
|
@ -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: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user