From 2fc083b494c5b88e04a5d39ee25a6cd4ec78c916 Mon Sep 17 00:00:00 2001 From: yuche Date: Thu, 1 Aug 2019 14:35:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformer):=20=E4=B8=8D=E4=BB=A5=20render?= =?UTF-8?q?=20=E5=BC=80=E5=A4=B4=E7=9A=84=20JSX=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=87=8D=E5=91=BD=E5=90=8D=20close=20#4036?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-transformer-wx/src/class-method-renamer.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/taro-transformer-wx/src/class-method-renamer.ts b/packages/taro-transformer-wx/src/class-method-renamer.ts index 21e2437139f0..44e88a9b6448 100644 --- a/packages/taro-transformer-wx/src/class-method-renamer.ts +++ b/packages/taro-transformer-wx/src/class-method-renamer.ts @@ -3,7 +3,7 @@ import * as t from 'babel-types' import { isDerivedFromThis } from './utils' function buildMethodName (n: string) { - return `render${n}` + return `render${n.charAt(0).toUpperCase() + n.slice(1)}` } export const buildVistor = () => { @@ -18,15 +18,20 @@ export const buildVistor = () => { let methodName = '' const classMethod = path.findParent(p => p.isClassMethod()) if (classMethod && classMethod.isClassMethod() && t.isIdentifier(classMethod.node.key)) { + methodName = classMethod.node.key.name if (methodName.startsWith('render')) { return } - methodName = classMethod.node.key.name + classMethod.node.key = t.identifier(buildMethodName(methodName)) } const classProp = path.findParent(p => p.isClassProperty()) if (classProp && classProp.isClassProperty()) { methodName = classProp.node.key.name + if (methodName.startsWith('render')) { + return + } + classProp.node.key = t.identifier(buildMethodName(methodName)) } if (methodName.length > 0 && !methodName.startsWith('render')) {