From ed6de3b360087de441cb3ac2b8f50bde365eb489 Mon Sep 17 00:00:00 2001 From: yuche Date: Thu, 11 Jul 2019 13:52:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(transformer):=20=E5=BF=AB=E5=BA=94?= =?UTF-8?q?=E7=94=A8=20$$event=20=E6=9B=B4=E5=90=8D=E4=B8=BA=20privateTaro?= =?UTF-8?q?Event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-transformer-wx/src/render.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/taro-transformer-wx/src/render.ts b/packages/taro-transformer-wx/src/render.ts index 204183ab8228..f18babc28c5a 100644 --- a/packages/taro-transformer-wx/src/render.ts +++ b/packages/taro-transformer-wx/src/render.ts @@ -2243,13 +2243,13 @@ export class RenderParser { setCustomEvent () { const classPath = this.renderPath.findParent(isClassDcl) as NodePath - const eventPropName = '$$events' + const eventPropName = Adapter.type === Adapters.quickapp ? 'privateTaroEvent' : '$$events' const body = classPath.node.body.body.find(b => t.isClassProperty(b) && b.key.name === eventPropName) as t.ClassProperty const usedEvents = Array.from(this.usedEvents).map(s => t.stringLiteral(s)) if (body && t.isArrayExpression(body.value)) { body.value = t.arrayExpression(uniq(body.value.elements.concat(usedEvents))) } else { - let classProp = t.classProperty(t.identifier('$$events'), t.arrayExpression(usedEvents)) as any // babel 6 typing 没有 static + let classProp = t.classProperty(t.identifier(eventPropName), t.arrayExpression(usedEvents)) as any // babel 6 typing 没有 static classProp.static = true classPath.node.body.body.unshift(classProp) }