Skip to content

Commit

Permalink
fix(transformer): 处理只有循环自定义的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jul 2, 2018
1 parent 4bb5092 commit 636c7a5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/taro-transformer-wx/src/class.ts
Expand Up @@ -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)
)
)
}
}
}

Expand Down

0 comments on commit 636c7a5

Please sign in to comment.