提交 e29ab96f 编写于 作者: Q qiang

fix: picker-view column question/132418

上级 8395a83b
......@@ -12,6 +12,7 @@ import {
ComponentInternalInstance,
onMounted,
ComponentPublicInstance,
nextTick,
} from 'vue'
import { defineBuiltInComponent } from '../../helpers/component'
import { flatVNode } from '../../helpers/flatVNode'
......@@ -103,6 +104,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
if (__PLATFORM__ !== 'app') {
onMounted(onMountedCallback)
}
let ColumnsPreRef: Ref<VNode[]> = ref([])
let columnsRef: Ref<VNode[] | HTMLCollection> = ref([])
function getItemIndex(vnode: VNode): number {
const columnVNodes = columnsRef.value
......@@ -112,7 +114,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
vnode.el
)
}
return (columnVNodes as VNode[]).indexOf(vnode)
let index: number = (columnVNodes as VNode[]).indexOf(vnode)
return index !== -1 ? index : ColumnsPreRef.value.indexOf(vnode)
}
const getPickerViewColumn: GetPickerViewColumn = function (columnInstance) {
const ref: WritableComputedRef<number> = computed({
......@@ -155,7 +158,11 @@ export default /*#__PURE__*/ defineBuiltInComponent({
const defaultSlots = slots.default && slots.default()
if (__PLATFORM__ !== 'app') {
// TODO filter
columnsRef.value = flatVNode(defaultSlots)
const vnode = flatVNode(defaultSlots)
ColumnsPreRef.value = vnode
nextTick(() => {
columnsRef.value = vnode
})
}
return (
<uni-picker-view ref={rootRef}>
......
......@@ -4368,10 +4368,12 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
const trigger = useCustomEvent(rootRef, emit2);
const state = useState$2(props2);
const resizeSensorRef = vue.ref(null);
let ColumnsPreRef = vue.ref([]);
let columnsRef = vue.ref([]);
function getItemIndex(vnode) {
const columnVNodes = columnsRef.value;
return columnVNodes.indexOf(vnode);
let index2 = columnVNodes.indexOf(vnode);
return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode);
}
const getPickerViewColumn = function(columnInstance) {
const ref = vue.computed({
......@@ -4403,7 +4405,11 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
return () => {
const defaultSlots = slots.default && slots.default();
{
columnsRef.value = flatVNode(defaultSlots);
const vnode = flatVNode(defaultSlots);
ColumnsPreRef.value = vnode;
vue.nextTick(() => {
columnsRef.value = vnode;
});
}
return vue.createVNode("uni-picker-view", {
"ref": rootRef
......
......@@ -10008,10 +10008,12 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
{
onMounted(onMountedCallback);
}
let ColumnsPreRef = ref([]);
let columnsRef = ref([]);
function getItemIndex(vnode) {
const columnVNodes = columnsRef.value;
return columnVNodes.indexOf(vnode);
let index2 = columnVNodes.indexOf(vnode);
return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode);
}
const getPickerViewColumn = function(columnInstance) {
const ref2 = computed({
......@@ -10043,7 +10045,11 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
return () => {
const defaultSlots = slots.default && slots.default();
{
columnsRef.value = flatVNode(defaultSlots);
const vnode = flatVNode(defaultSlots);
ColumnsPreRef.value = vnode;
nextTick(() => {
columnsRef.value = vnode;
});
}
return createVNode("uni-picker-view", {
"ref": rootRef
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册