diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
index f2385697fdb92c0b262a6389eabfe68373ef6f8a..d5b1d2d6327e29249fa69a55dc79262ae9e67e3e 100644
--- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
@@ -797,6 +797,16 @@ describe('mp:compiler-extra', () => {
'{{$root.m1}}',
'with(this){var m0=test1(key)&&test2(key);var m1=m0?getValue(key):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}'
)
+ assertCodegen(
+ '{{getValue(key)}}',
+ '{{$root.m0}}',
+ 'with(this){var g0=test.test(key)&&test2(key);var m0=g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
+ )
+ assertCodegen(
+ '{{getValue(key)}}',
+ '{{$root.m0}}',
+ 'with(this){var g0=show?test.test(key)&&test2(key):null;var m0=show&&g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
+ )
assertCodegen(
'{{getValue(item)}}',
'{{item.m0}}',
diff --git a/packages/uni-template-compiler/lib/script/traverse/visitor.js b/packages/uni-template-compiler/lib/script/traverse/visitor.js
index bec219549cb607ac8c30b56e308d17465b2dba4b..08f3bd4d4d25057148f80b02db4577c6cd9a3f54 100644
--- a/packages/uni-template-compiler/lib/script/traverse/visitor.js
+++ b/packages/uni-template-compiler/lib/script/traverse/visitor.js
@@ -251,6 +251,11 @@ module.exports = {
t.isMemberExpression(callee) // message.split('').reverse().join('')
) {
// Object.assign...
+ path = path.findParent((path) => path.isLogicalExpression()) || path
+ path.skip()
+ if (path.findParent((path) => path.shouldSkip)) {
+ return
+ }
path.replaceWith(getMemberExpr(path, IDENTIFIER_GLOBAL, path.node, this))
}
},