fix: virtual list ts error

feat-dayjs
Amour1688 2020-10-17 12:14:13 +08:00
parent df771a8fc6
commit 4fc1a3cd78
5 changed files with 10 additions and 10 deletions

View File

@ -2,7 +2,7 @@ export interface RefObject extends Function {
current?: any; current?: any;
} }
function createRef(): RefObject { function createRef(): any {
const func: RefObject = (node: any) => { const func: RefObject = (node: any) => {
func.current = node; func.current = node;
}; };

View File

@ -237,7 +237,6 @@ const SelectSelector = defineComponent<SelectorProps>({
onInputMouseDown, onInputMouseDown,
onInputCompositionStart, onInputCompositionStart,
onInputCompositionEnd, onInputCompositionEnd,
choiceTransitionName,
} = props; } = props;
return ( return (
<> <>

View File

@ -9,7 +9,7 @@ const Item: FunctionalComponent<ItemProps> = ({ setRef }, { slots }) => {
return children && children.length return children && children.length
? cloneVNode(children[0], { ? cloneVNode(children[0], {
ref: setRef, ref: setRef as any,
}) })
: children; : children;
}; };
@ -19,4 +19,5 @@ Item.props = {
default: () => {}, default: () => {},
}, },
}; };
export default Item; export default Item;

View File

@ -45,7 +45,7 @@ function renderChildren<T>(
}); });
const key = getKey(item); const key = getKey(item);
return ( return (
<Item key={key} setRef={ele => setNodeRef(item, ele)}> <Item key={key} setRef={ele => setNodeRef(item, ele as HTMLElement)}>
{node} {node}
</Item> </Item>
); );
@ -102,7 +102,7 @@ const List = defineComponent({
mergedData: computed(() => props.data || EMPTY_DATA) as any, mergedData: computed(() => props.data || EMPTY_DATA) as any,
}); });
const componentRef = ref<Element>(); const componentRef = ref<HTMLDivElement>();
// =============================== Item Key =============================== // =============================== Item Key ===============================
const getKey = (item: Record<string, any>) => { const getKey = (item: Record<string, any>) => {
@ -257,8 +257,8 @@ const List = defineComponent({
const removeEventListener = () => { const removeEventListener = () => {
if (componentRef.value) { if (componentRef.value) {
componentRef.value.removeEventListener('wheel', onRawWheel); componentRef.value.removeEventListener('wheel', onRawWheel);
componentRef.value.removeEventListener('DOMMouseScroll' as any, onFireFoxScroll); componentRef.value.removeEventListener('DOMMouseScroll', onFireFoxScroll as any);
componentRef.value.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll); componentRef.value.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
} }
}; };
watchEffect(() => { watchEffect(() => {
@ -266,8 +266,8 @@ const List = defineComponent({
if (componentRef.value) { if (componentRef.value) {
removeEventListener(); removeEventListener();
componentRef.value.addEventListener('wheel', onRawWheel); componentRef.value.addEventListener('wheel', onRawWheel);
componentRef.value.addEventListener('DOMMouseScroll' as any, onFireFoxScroll); componentRef.value.addEventListener('DOMMouseScroll', onFireFoxScroll as any);
componentRef.value.addEventListener('MozMousePixelScroll', onMozMousePixelScroll); componentRef.value.addEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
} }
}); });
}); });

View File

@ -4,7 +4,7 @@ const SMOOTH_PTG = 14 / 15;
export default function useMobileTouchMove( export default function useMobileTouchMove(
inVirtual: Ref<boolean>, inVirtual: Ref<boolean>,
listRef: Ref<Element | undefined>, listRef: Ref<HTMLDivElement | undefined>,
callback: (offsetY: number, smoothOffset?: boolean) => boolean, callback: (offsetY: number, smoothOffset?: boolean) => boolean,
) { ) {
let touched = false; let touched = false;