test 列表刷新
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -7,5 +7,4 @@ export type ClSelectPickerViewProps = {
|
||||
columns?: ClSelectOption[][];
|
||||
itemHeight?: number;
|
||||
height?: number;
|
||||
resetOnChange?: boolean;
|
||||
};
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
4
uni_modules/cool-ui/types/component.d.ts
vendored
4
uni_modules/cool-ui/types/component.d.ts
vendored
@@ -126,6 +126,10 @@ declare type ClListItemComponentPublicInstance = {
|
||||
initSwipe: () => void;
|
||||
};
|
||||
|
||||
declare type ClListViewComponentPublicInstance = {
|
||||
data: ClListViewItem[];
|
||||
};
|
||||
|
||||
declare type ClCascaderComponentPublicInstance = {
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
|
||||
@@ -105,7 +105,7 @@ export type ClListItem = {
|
||||
};
|
||||
|
||||
export type ClListViewItem = {
|
||||
label: string;
|
||||
label?: string;
|
||||
value?: any;
|
||||
index?: string;
|
||||
children?: ClListViewItem[];
|
||||
|
||||
Reference in New Issue
Block a user