diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
index d0d8214b944401b0408f8b559df5fe9315846ee1..4f9a3016becc4bfab864d40df1face5f4ac2f877 100644
--- a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
@@ -132,6 +132,10 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen('', '')
assertCodegen('', '', 'with(this){var a0={"x":0};$mp.data=Object.assign({},{$root:{a0:a0}})}')
+ assertCodegen(
+ '', '',
+ 'with(this){var a0={x:{x:0}};$mp.data=Object.assign({},{$root:{a0:a0}})}'
+ )
})
it('generate v-show directive', () => {
diff --git a/packages/uni-template-compiler/lib/script/traverse/data/attrs.js b/packages/uni-template-compiler/lib/script/traverse/data/attrs.js
index 644986879e9c18e229349e052017af620cb1f188..394b88bf9331aa7a169510a8e1b874ea5ea3bd24 100644
--- a/packages/uni-template-compiler/lib/script/traverse/data/attrs.js
+++ b/packages/uni-template-compiler/lib/script/traverse/data/attrs.js
@@ -12,7 +12,7 @@ module.exports = function processAttrs (paths, path, state, isComponent, tagName
attrsPath.get('value.properties').forEach(propertyPath => {
const valuePath = propertyPath.get('value')
// 对于普通的ObjectExpression不再单独处理,改为在转换temlplte时用()包裹(微信、QQ)
- if (valuePath.isObjectExpression() && valuePath.node.properties.find(({ key }) => !t.isIdentifier(key))) {
+ if (valuePath.isObjectExpression() && valuePath.node.properties.find(({ key, value }) => !t.isIdentifier(key) || !(t.isIdentifier(value) || t.isStringLiteral(value) || t.isBooleanLiteral(value) || t.isNumericLiteral(value) || t.isNullLiteral(value)))) {
valuePath.replaceWith(getMemberExpr(path, IDENTIFIER_ATTR, valuePath.node, state))
}
})