diff --git a/packages/taroize/src/script.ts b/packages/taroize/src/script.ts index 9715da214545..2e7bd56b635d 100644 --- a/packages/taroize/src/script.ts +++ b/packages/taroize/src/script.ts @@ -81,7 +81,11 @@ export function parseScript ( if (componentType !== 'App') { classDecl.decorators = [buildDecorator(componentType)] } - path.insertAfter(t.exportDefaultDeclaration(t.identifier(defaultClassName))) + ast.program.body.push( + classDecl, + t.exportDefaultDeclaration(t.identifier(componentType !== 'App' ? defaultClassName : 'App')) + ) + // path.insertAfter(t.exportDefaultDeclaration(t.identifier(defaultClassName))) path.remove() } } diff --git a/packages/taroize/src/wxml.ts b/packages/taroize/src/wxml.ts index 5f88d36ade03..d409b7400842 100644 --- a/packages/taroize/src/wxml.ts +++ b/packages/taroize/src/wxml.ts @@ -582,15 +582,22 @@ function parseContent (content: string) { function parseAttribute (attr: Attribute) { const { key, value } = attr - let jsxValue: null | t.JSXExpressionContainer | t.StringLiteral = null if (value) { const { type, content } = parseContent(value) + let expr: t.Expression + if (content.includes(':') && content.startsWith('(') && content.endsWith(')')) { + const [ key, value ] = content.slice(1, content.length - 1).split(':') + expr = t.objectExpression([t.objectProperty(t.stringLiteral(key), buildTemplate(value))]) + } + if (!expr!) { + expr = buildTemplate(content) + } jsxValue = type === 'raw' ? t.stringLiteral(content) - : t.jSXExpressionContainer(buildTemplate(content)) + : t.jSXExpressionContainer(expr!) } const jsxKey = handleAttrKey(key)