diff --git a/packages/vant/src/list/List.tsx b/packages/vant/src/list/List.tsx index afdc76a43..d81edc489 100644 --- a/packages/vant/src/list/List.tsx +++ b/packages/vant/src/list/List.tsx @@ -34,6 +34,7 @@ export const listProps = { error: Boolean, offset: makeNumericProp(300), loading: Boolean, + disabled: Boolean, finished: Boolean, errorText: String, direction: makeStringProp('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 (
{slots.loading ? ( diff --git a/packages/vant/src/list/README.md b/packages/vant/src/list/README.md index 65a4c1925..bba6b4f40 100644 --- a/packages/vant/src/list/README.md +++ b/packages/vant/src/list/README.md @@ -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 diff --git a/packages/vant/src/list/README.zh-CN.md b/packages/vant/src/list/README.zh-CN.md index 707aaceef..e56f0e08e 100644 --- a/packages/vant/src/list/README.zh-CN.md +++ b/packages/vant/src/list/README.zh-CN.md @@ -190,6 +190,7 @@ export default { | finished-text | 加载完成后的提示文案 | _string_ | - | | error-text | 加载失败后的提示文案 | _string_ | - | | immediate-check | 是否在初始化时立即执行滚动位置检查 | _boolean_ | `true` | +| disabled | 是否禁用滚动加载 | _boolean_ | `false` | | direction | 滚动触发加载的方向,可选值为 `up` | _string_ | `down` | ### Events diff --git a/packages/vant/src/list/test/index.spec.jsx b/packages/vant/src/list/test/index.spec.jsx index 0c2d27649..dabf11aac 100644 --- a/packages/vant/src/list/test/index.spec.jsx +++ b/packages/vant/src/list/test/index.spec.jsx @@ -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: {