Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/uni-mp-alipay/src/runtime/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function handleRef(this: MPComponentInstance, ref: MPComponentInstance) {
if (isString(refInForName)) {
;(refs[refInForName] || (refs[refInForName] = [])).push(refValue)
} else {
setRef(refInForName, refValue, refs, setupState)
setRef(refInForName, refValue, refs, setupState, true)
}
}
}
Expand All @@ -170,14 +170,26 @@ function setRef(
ref: Ref | ((ref: object | null, refs: Record<string, any>) => void),
refValue: ComponentPublicInstance,
refs: Record<string, unknown>,
setupState: Data
setupState: Data,
isRefInVFor = false
) {
if (isRef(ref)) {
ref.value = refValue
} else if (isFunction(ref)) {
const templateRef = ref(refValue, refs)
if (isTemplateRef(templateRef)) {
setTemplateRef(templateRef, refValue, setupState)
// 对于 template ref,需要手动同步到 refs,否则 getCurrentInstance().proxy.$refs 获取不到
if (!templateRef.k || !isRef(templateRef.r)) {
return
}
if (isRefInVFor) {
;(
(refs[templateRef.k] || (refs[templateRef.k] = [])) as unknown[]
).push(refValue)
} else {
refs[templateRef.k] = refValue
}
}
}
}
Expand Down
Loading