diff --git a/packages/taro-transformer-wx/src/utils.ts b/packages/taro-transformer-wx/src/utils.ts index e49d071515ec..ea879bd36ea0 100644 --- a/packages/taro-transformer-wx/src/utils.ts +++ b/packages/taro-transformer-wx/src/utils.ts @@ -659,7 +659,7 @@ export function setAncestorCondition (jsx: NodePath, expr: t.Expression) Adapter.if, Adapter.else ]) - const logicalJSX = jsx.findParent(p => p.isJSXElement() && p.node.openingElement.attributes.some(a => ifAttrSet.has(a.name.name as string))) as NodePath + const logicalJSX = jsx.findParent(p => p.isJSXElement() && p.node.openingElement.attributes.some(a => t.isIdentifier(a.name) && ifAttrSet.has(a.name.name))) as NodePath if (logicalJSX) { const attr = logicalJSX.node.openingElement.attributes.find(a => ifAttrSet.has(a.name.name as string)) if (attr) {