提交 63a59f52 编写于 作者: Q qiang

fix: 修复小程序 v-for 中嵌套复杂事件表达式编译报错的问题

上级 6695421e
......@@ -327,6 +327,11 @@ describe('mp:compiler-extra', () => {
'<view><view class="item" v-for="i in 5" :key="i" @click="func(i)"></view></view>',
'<view><block wx:for="{{5}}" wx:for-item="i" wx:for-index="__i0__" wx:key="*this"><view data-event-opts="{{[[\'tap\',[[\'func\',[\'$0\'],[[[5,\'\',__i0__]]]]]]]}}" class="item" bindtap="__e"></view></block></view>'
)
assertCodegen(
'<view v-for="(item,index) in list" :key="index"><view @click="$test.test(item,item.length)"></view></view>',
'<block wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><view data-event-opts="{{[[\'tap\',[[\'e0\',[\'$event\']]]]]}}" data-event-params="{{({item})}}" bindtap="__e"></view></view></block>',
'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', () => {
......
......@@ -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)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册