feat(List): add disabled prop (#11307)

This commit is contained in:
neverland 2022-11-26 20:05:33 +08:00 committed by GitHub
parent 69b5ea6348
commit d227429fdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export const listProps = {
error: Boolean,
offset: makeNumericProp(300),
loading: Boolean,
disabled: Boolean,
finished: Boolean,
errorText: String,
direction: makeStringProp<ListDirection>('down'),
@ -64,6 +65,7 @@ export default defineComponent({
if (
loading.value ||
props.finished ||
props.disabled ||
props.error ||
// skip check when inside an inactive tab
tabStatus?.value === false
@ -129,7 +131,7 @@ export default defineComponent({
};
const renderLoading = () => {
if (loading.value && !props.finished) {
if (loading.value && !props.finished && !props.disabled) {
return (
<div class={bem('loading')}>
{slots.loading ? (

View File

@ -175,6 +175,7 @@ export default {
| finished-text | Finished text | _string_ | - |
| error-text | Error loaded text | _string_ | - |
| immediate-check | Whether to check loading position immediately after mounted | _boolean_ | `true` |
| disabled | Whether to disable the load event | _boolean_ | `false` |
| direction | Scroll direction, can be set to `up` | _string_ | `down` |
### Events

View File

@ -190,6 +190,7 @@ export default {
| finished-text | 加载完成后的提示文案 | _string_ | - |
| error-text | 加载失败后的提示文案 | _string_ | - |
| immediate-check | 是否在初始化时立即执行滚动位置检查 | _boolean_ | `true` |
| disabled | 是否禁用滚动加载 | _boolean_ | `false` |
| direction | 滚动触发加载的方向,可选值为 `up` | _string_ | `down` |
### Events

View File

@ -12,6 +12,18 @@ test('should emit load event when reaching bottom', async () => {
wrapper.unmount();
});
test('should not emit load event when disabled', async () => {
const wrapper = mount(List, {
props: {
disabled: true,
},
});
await later();
expect(wrapper.emitted('load')).toBeFalsy();
expect(wrapper.emitted('update:loading')).toBeFalsy();
});
test('should reload after clicking the error text', async () => {
const wrapper = mount(List, {
props: {