From 9e664954a2cc21ed67871535c9ca792a3c1ef28d Mon Sep 17 00:00:00 2001 From: yuche Date: Tue, 23 Oct 2018 10:48:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformer):=20=E4=BD=BF=E7=94=A8=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E5=9C=A8=20this=20=E4=B8=8B=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=B8=B2=E6=9F=93=E5=8F=AF=E8=83=BD=E4=BC=9A=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= 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 3cf8590c2a0f..8bd7b5a988a5 100644 --- a/packages/taro-transformer-wx/src/render.ts +++ b/packages/taro-transformer-wx/src/render.ts @@ -1331,7 +1331,7 @@ export class RenderParser { this.renderPath.node.body.body.unshift( template(`this.__state = arguments[0] || this.state || {};`)(), template(`this.__props = arguments[1] || this.props || {};`)(), - t.variableDeclaration( + this.usedThisProperties.size ? t.variableDeclaration( 'const', [ t.variableDeclarator( @@ -1342,7 +1342,7 @@ export class RenderParser { t.thisExpression() ) ] - ) + ) : t.emptyStatement() ) if (t.isIdentifier(this.renderPath.node.key)) {