test 列表刷新

This commit is contained in:
icssoa
2025-08-08 09:36:31 +08:00
parent 816b5f1585
commit 4f8bd2c54b
9 changed files with 157 additions and 13 deletions

View File

@@ -18,7 +18,10 @@
direction="vertical"
@scroll="onScroll"
>
<view class="cl-list-view__virtual-list" :style="{ height: listHeight + 'px' }">
<view
class="cl-list-view__virtual-list"
:style="{ height: virtual ? listHeight + 'px' : 'auto' }"
>
<view class="cl-list-view__spacer-top" :style="{ height: spacerTopHeight + 'px' }">
<slot name="top"></slot>
</view>
@@ -54,14 +57,12 @@
},
pt.item?.className
]"
:hover-class="parseClass([[isDark, '!bg-surface-800', '!bg-surface-50']])"
:hover-stay-time="50"
:style="{
height: itemHeight + 'px'
height: virtual ? itemHeight + 'px' : 'auto'
}"
@tap="onItemTap(item)"
>
<slot name="item" :data="item.data" :item="item">
<slot name="item" :item="item" :data="item.data" :value="item.data.value">
<view class="cl-list-view__item-inner">
<cl-text> {{ item.data.label }} </cl-text>
</view>
@@ -133,7 +134,7 @@ defineSlots<{
// 分组头部插槽
header(props: { index: string }): any;
// 列表项插槽
item(props: { data: ClListViewItem; item: VirtualItem }): any;
item(props: { data: ClListViewItem; item: VirtualItem; value: any | null }): any;
// 底部插槽
bottom(): any;
// 索引插槽
@@ -490,6 +491,10 @@ onMounted(() => {
}
);
});
defineExpose({
data
});
</script>
<style lang="scss" scoped>

View File

@@ -7,5 +7,4 @@ export type ClSelectPickerViewProps = {
columns?: ClSelectOption[][];
itemHeight?: number;
height?: number;
resetOnChange?: boolean;
};

View File

@@ -2,7 +2,12 @@ import { parse } from "@/cool";
import type { ClCascaderOption, ClListViewItem } from "../types";
export function useListView(data: UTSJSONObject[]) {
return data.map((e) => parse<ClListViewItem>(e)!);
return data.map((e) => {
return parse<ClListViewItem>({
...e,
value: e
})!;
});
}
export function useCascader(data: UTSJSONObject[]) {

View File

@@ -126,6 +126,10 @@ declare type ClListItemComponentPublicInstance = {
initSwipe: () => void;
};
declare type ClListViewComponentPublicInstance = {
data: ClListViewItem[];
};
declare type ClCascaderComponentPublicInstance = {
open: () => void;
close: () => void;

View File

@@ -105,7 +105,7 @@ export type ClListItem = {
};
export type ClListViewItem = {
label: string;
label?: string;
value?: any;
index?: string;
children?: ClListViewItem[];