From 63a59f52d687356f6da02b7403007398656b8b53 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 13 Aug 2020 14:51:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=20v-for=20=E4=B8=AD=E5=B5=8C=E5=A5=97=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E4=BA=8B=E4=BB=B6=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-template-compiler/__tests__/compiler-extra.spec.js | 5 +++++ .../uni-template-compiler/lib/script/traverse/data/event.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js index a5880d491..3cee2701b 100644 --- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js @@ -327,6 +327,11 @@ describe('mp:compiler-extra', () => { '', '' ) + assertCodegen( + '', + '', + 'with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return $test.test(item,item.length)}}}' + ) }) it('generate class binding', () => { diff --git a/packages/uni-template-compiler/lib/script/traverse/data/event.js b/packages/uni-template-compiler/lib/script/traverse/data/event.js index 698c08151..c5e9dc25e 100644 --- a/packages/uni-template-compiler/lib/script/traverse/data/event.js +++ b/packages/uni-template-compiler/lib/script/traverse/data/event.js @@ -335,7 +335,7 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false, const scope = path.scope const node = path.node const name = node.name - if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed) && scope && !scope.hasOwnBinding(name) && scope.hasBinding(name)) { + if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed) && scope && !scope.hasOwnBinding(name) && scope.hasBinding(name) && !params.includes(name)) { params.push(name) } } -- GitLab