From ce61aa68eec25e530c0170257dc2393f72311075 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 29 Dec 2021 20:09:09 +0800 Subject: [PATCH] fix(App): picker-view --- .../src/components/picker-view/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/uni-components/src/components/picker-view/index.tsx b/packages/uni-components/src/components/picker-view/index.tsx index ae283bf28..e237e691c 100644 --- a/packages/uni-components/src/components/picker-view/index.tsx +++ b/packages/uni-components/src/components/picker-view/index.tsx @@ -105,15 +105,18 @@ export default /*#__PURE__*/ defineBuiltInComponent({ onMounted(onMountedCallback) } let ColumnsPreRef: Ref = ref([]) + // app HTMLCollection, H5 VNode[] let columnsRef: Ref = ref([]) function getItemIndex(vnode: VNode): number { - const columnVNodes = (columnsRef.value as VNode[]).filter( - (ref) => typeof ref.type !== 'symbol' - ) - if (__PLATFORM__ === 'app' && columnVNodes) { + let columnVNodes = columnsRef.value + if (__PLATFORM__ === 'app' && columnVNodes instanceof HTMLCollection) { return Array.prototype.indexOf.call(columnVNodes, vnode.el) + } else { + columnVNodes = (columnVNodes as VNode[]).filter( + (ref) => typeof ref.type !== 'symbol' + ) } - let index: number = columnVNodes.indexOf(vnode) + let index: number = (columnVNodes as VNode[]).indexOf(vnode) return index !== -1 ? index : ColumnsPreRef.value.indexOf(vnode) } const getPickerViewColumn: GetPickerViewColumn = function (columnInstance) { -- GitLab