mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
feat(List): add disabled prop (#11307)
This commit is contained in:
parent
69b5ea6348
commit
d227429fdc
@ -34,6 +34,7 @@ export const listProps = {
|
|||||||
error: Boolean,
|
error: Boolean,
|
||||||
offset: makeNumericProp(300),
|
offset: makeNumericProp(300),
|
||||||
loading: Boolean,
|
loading: Boolean,
|
||||||
|
disabled: Boolean,
|
||||||
finished: Boolean,
|
finished: Boolean,
|
||||||
errorText: String,
|
errorText: String,
|
||||||
direction: makeStringProp<ListDirection>('down'),
|
direction: makeStringProp<ListDirection>('down'),
|
||||||
@ -64,6 +65,7 @@ export default defineComponent({
|
|||||||
if (
|
if (
|
||||||
loading.value ||
|
loading.value ||
|
||||||
props.finished ||
|
props.finished ||
|
||||||
|
props.disabled ||
|
||||||
props.error ||
|
props.error ||
|
||||||
// skip check when inside an inactive tab
|
// skip check when inside an inactive tab
|
||||||
tabStatus?.value === false
|
tabStatus?.value === false
|
||||||
@ -129,7 +131,7 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderLoading = () => {
|
const renderLoading = () => {
|
||||||
if (loading.value && !props.finished) {
|
if (loading.value && !props.finished && !props.disabled) {
|
||||||
return (
|
return (
|
||||||
<div class={bem('loading')}>
|
<div class={bem('loading')}>
|
||||||
{slots.loading ? (
|
{slots.loading ? (
|
||||||
|
@ -175,6 +175,7 @@ export default {
|
|||||||
| finished-text | Finished text | _string_ | - |
|
| finished-text | Finished text | _string_ | - |
|
||||||
| error-text | Error loaded text | _string_ | - |
|
| error-text | Error loaded text | _string_ | - |
|
||||||
| immediate-check | Whether to check loading position immediately after mounted | _boolean_ | `true` |
|
| 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` |
|
| direction | Scroll direction, can be set to `up` | _string_ | `down` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
@ -190,6 +190,7 @@ export default {
|
|||||||
| finished-text | 加载完成后的提示文案 | _string_ | - |
|
| finished-text | 加载完成后的提示文案 | _string_ | - |
|
||||||
| error-text | 加载失败后的提示文案 | _string_ | - |
|
| error-text | 加载失败后的提示文案 | _string_ | - |
|
||||||
| immediate-check | 是否在初始化时立即执行滚动位置检查 | _boolean_ | `true` |
|
| immediate-check | 是否在初始化时立即执行滚动位置检查 | _boolean_ | `true` |
|
||||||
|
| disabled | 是否禁用滚动加载 | _boolean_ | `false` |
|
||||||
| direction | 滚动触发加载的方向,可选值为 `up` | _string_ | `down` |
|
| direction | 滚动触发加载的方向,可选值为 `up` | _string_ | `down` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
@ -12,6 +12,18 @@ test('should emit load event when reaching bottom', async () => {
|
|||||||
wrapper.unmount();
|
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 () => {
|
test('should reload after clicking the error text', async () => {
|
||||||
const wrapper = mount(List, {
|
const wrapper = mount(List, {
|
||||||
props: {
|
props: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user