From 2b215b0f79d1b55003fecd05d48253071d891bde Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 29 Nov 2021 17:26:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20picker-view-column=20v-if=20=E6=97=B6?= =?UTF-8?q?=E6=9C=89=E5=8D=A0=E4=BD=8D=20question/132545?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/picker-view/index.tsx | 13 ++++++------- packages/uni-h5/dist/uni-h5.cjs.js | 2 +- packages/uni-h5/dist/uni-h5.es.js | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/uni-components/src/components/picker-view/index.tsx b/packages/uni-components/src/components/picker-view/index.tsx index 62d5061eb..ae283bf28 100644 --- a/packages/uni-components/src/components/picker-view/index.tsx +++ b/packages/uni-components/src/components/picker-view/index.tsx @@ -107,14 +107,13 @@ export default /*#__PURE__*/ defineBuiltInComponent({ let ColumnsPreRef: Ref = ref([]) let columnsRef: Ref = ref([]) function getItemIndex(vnode: VNode): number { - const columnVNodes = columnsRef.value - if (__PLATFORM__ === 'app' && columnVNodes instanceof HTMLCollection) { - return Array.prototype.indexOf.call( - columnVNodes as HTMLCollection, - vnode.el - ) + const columnVNodes = (columnsRef.value as VNode[]).filter( + (ref) => typeof ref.type !== 'symbol' + ) + if (__PLATFORM__ === 'app' && columnVNodes) { + return Array.prototype.indexOf.call(columnVNodes, vnode.el) } - let index: number = (columnVNodes as VNode[]).indexOf(vnode) + let index: number = columnVNodes.indexOf(vnode) return index !== -1 ? index : ColumnsPreRef.value.indexOf(vnode) } const getPickerViewColumn: GetPickerViewColumn = function (columnInstance) { diff --git a/packages/uni-h5/dist/uni-h5.cjs.js b/packages/uni-h5/dist/uni-h5.cjs.js index d6fe6a1c6..8e3bc4fc4 100644 --- a/packages/uni-h5/dist/uni-h5.cjs.js +++ b/packages/uni-h5/dist/uni-h5.cjs.js @@ -4378,7 +4378,7 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({ let ColumnsPreRef = vue.ref([]); let columnsRef = vue.ref([]); function getItemIndex(vnode) { - const columnVNodes = columnsRef.value; + const columnVNodes = columnsRef.value.filter((ref) => typeof ref.type !== "symbol"); let index2 = columnVNodes.indexOf(vnode); return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode); } diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 8667bd294..99070b595 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -10113,7 +10113,7 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({ let ColumnsPreRef = ref([]); let columnsRef = ref([]); function getItemIndex(vnode) { - const columnVNodes = columnsRef.value; + const columnVNodes = columnsRef.value.filter((ref2) => typeof ref2.type !== "symbol"); let index2 = columnVNodes.indexOf(vnode); return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode); } -- GitLab