From 636c7a54b6c645edd6a32f94647c7b0e41fe0d11 Mon Sep 17 00:00:00 2001 From: yuche Date: Tue, 3 Jul 2018 01:52:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformer):=20=E5=A4=84=E7=90=86=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E5=BE=AA=E7=8E=AF=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-transformer-wx/src/class.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/taro-transformer-wx/src/class.ts b/packages/taro-transformer-wx/src/class.ts index 52e392171e01..f3d428af4e3a 100644 --- a/packages/taro-transformer-wx/src/class.ts +++ b/packages/taro-transformer-wx/src/class.ts @@ -354,17 +354,27 @@ class Transformer { t.objectProperty(t.identifier(uuid), t.arrowFunctionExpression([], t.blockStatement(blockStatement))) ) }) + let hasDynamicComponents = false for (const property of this.classPath.node.body.body) { if ( t.isClassProperty(property) && property.key.name === '$dynamicComponents' && t.isObjectExpression(property.value) ) { + hasDynamicComponents = true property.value = t.objectExpression( property.value.properties.concat(properties) ) } } + if (!hasDynamicComponents) { + this.classPath.node.body.body.unshift( + t.classProperty( + t.identifier('$dynamicComponents'), + t.objectExpression(properties) + ) + ) + } } }