From 5fd95628cc8c0f2b014ab8897b3f29cf34eccb80 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 7 Apr 2022 16:20:59 +0800 Subject: [PATCH] fix(mp): fix edge case when slot is undefined (#3346) --- packages/uni-mp-vue/src/helpers/withScopedSlot.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/uni-mp-vue/src/helpers/withScopedSlot.ts b/packages/uni-mp-vue/src/helpers/withScopedSlot.ts index dc3396f61..a9162f393 100644 --- a/packages/uni-mp-vue/src/helpers/withScopedSlot.ts +++ b/packages/uni-mp-vue/src/helpers/withScopedSlot.ts @@ -57,6 +57,10 @@ function createScopedSlotInvoker(instance: ComponentInternalInstance) { index?: number ) => { const slot = invoker.slots[slotName] + if (!slot) { + // slot 可能不存在 https://github.com/dcloudio/uni-app/issues/3346 + return + } const hasIndex = typeof index !== 'undefined' index = index || 0 // 确保当前 slot 的上下文,类似 withCtx -- GitLab