From ee93e114f9d98ab8aa07b68385883c478cd44f16 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 8 Apr 2021 18:07:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(mp-alipay):=20=E4=BF=AE=E5=A4=8D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E9=BB=98=E8=AE=A4=E6=8F=92=E6=A7=BD=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=86=85=E5=AE=B9=E4=B8=80=E7=9B=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20question/116404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/compiler-mp-alipay.spec.js | 6 ++++++ packages/uni-template-compiler/lib/template/traverse.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js index d31ab3f31..4541914ab 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js @@ -55,6 +55,12 @@ describe('mp:compiler-mp-alipay', () => { } ) }) + it('generate slot fallback content', () => { + assertCodegen( + 'slot', + 'slot' + ) + }) it('generate default slot', () => { assertCodegen( 'text', diff --git a/packages/uni-template-compiler/lib/template/traverse.js b/packages/uni-template-compiler/lib/template/traverse.js index 4107551fe..ae1c59ce7 100644 --- a/packages/uni-template-compiler/lib/template/traverse.js +++ b/packages/uni-template-compiler/lib/template/traverse.js @@ -273,6 +273,10 @@ function genSlotNode (slotName, slotNode, fallbackNodes, state) { if (!fallbackNodes || t.isNullLiteral(fallbackNodes)) { return slotNode } + // 支付宝小程序默认插槽为 $default + if (state.options.platform.name === 'mp-alipay') { + slotName = slotName === 'default' ? '$default' : slotName + } const prefix = state.options.platform.directive return [{ type: 'block', -- GitLab