mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(List): add error slot
This commit is contained in:
parent
8a0705d761
commit
e9a9388202
@ -133,3 +133,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 |
|
||||
| error | Custom error tips |
|
||||
|
@ -140,6 +140,7 @@ export default {
|
||||
| default | 列表内容 |
|
||||
| loading | 自定义底部加载中提示 |
|
||||
| finished | 自定义加载完成后的提示文案 |
|
||||
| error | 自定义加载失败后的提示文案 |
|
||||
|
||||
## 常见问题
|
||||
|
||||
|
@ -136,12 +136,16 @@ export default createComponent({
|
||||
},
|
||||
|
||||
genErrorText() {
|
||||
if (this.error && this.errorText) {
|
||||
return (
|
||||
<div onClick={this.clickErrorText} class={bem('error-text')}>
|
||||
{this.errorText}
|
||||
</div>
|
||||
);
|
||||
if (this.error) {
|
||||
const text = this.slots('error') || this.errorText;
|
||||
|
||||
if (text) {
|
||||
return (
|
||||
<div onClick={this.clickErrorText} class={bem('error-text')}>
|
||||
{text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,5 +1,12 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`error slot 1`] = `
|
||||
<div role="feed" class="van-list">
|
||||
<div class="van-list__error-text">Custom Error</div>
|
||||
<div class="van-list__placeholder"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`finished slot 1`] = `
|
||||
<div role="feed" class="van-list">
|
||||
<div class="van-list__finished-text">Custom Finished</div>
|
||||
|
@ -83,6 +83,19 @@ test('finished slot', async () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('error slot', async () => {
|
||||
const wrapper = mount(List, {
|
||||
propsData: {
|
||||
error: true
|
||||
},
|
||||
scopedSlots: {
|
||||
error: () => 'Custom Error'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('immediate check false', async () => {
|
||||
const wrapper = mount(List, {
|
||||
propsData: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user