提交 0c92985c 编写于 作者: fxy060608's avatar fxy060608

fix(v3): v-for in scoped slots

上级 affafb58
......@@ -79,6 +79,14 @@ describe('codegen', () => {
'<current-user>ABCD</current-user>',
`with(this){return _c('current-user',{attrs:{"_i":0}},[_v("")])}`
)
assertCodegen(
`<current-user>
<template v-slot:default="{result}">
<view v-for="(item,index) in result.list">{{item.name}}</view>
</template>
</current-user>`,
`with(this){return _c('current-user',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function({result}, _svm, _si){return _l((_svm._$s(("2-"+_si),'f',{forItems:result.list})),function(item,index,$20,$30){return _c('view',{key:_svm._$s(("2-"+_si),'f',{forIndex:$20,key:("2-"+_si)+'-'+$30}),attrs:{"_i":(("2-"+_si)+$30)}},[_v((_svm._$s((("2-"+_si)+$30),'t0',_s(item.name))))])})}}])})}`
)
})
it('generate keep-alive', () => {
......
const compiler = require('../lib')
const res = compiler.compile(
`
<foo><template v-if="show" #default="bar">{{ bar }}</template></foo>
<current-user>
<template v-slot:default="{result}">
<view v-for="(item,index) in result.list">{{item.name}}</view>
</template>
</current-user>
`, {
resourcePath: '/User/fxy/Documents/test.wxml',
isReservedTag: function (tag) {
......@@ -14,7 +18,7 @@ const res = compiler.compile(
platform: 'app-plus'
},
filterModules: ['swipe'],
// service: true,
service: true,
view: true
})
......
......@@ -100,7 +100,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs(el, genVar)
parseFor(el, createGenVar, isScopedSlot)
parseKey(el)
parseKey(el, isScopedSlot)
parseIf(el, createGenVar, isScopedSlot)
parseBinding(el, genVar)
......
......@@ -119,6 +119,9 @@ function updateScopedSlotEleId (el, state) {
}
const it = '_si'
const newId = getNewId(el.attrsMap[ID], it)
if (el.forId) {
el.forId = getNewId(el.forId, it)
}
addRawAttr(el, ID, newId)
if (el.attrs) {
const attr = el.attrs.find(attr => attr.name === ID)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册