提交 63aa08d4 编写于 作者: fxy060608's avatar fxy060608

fix(mp): dynamic scoped slot

上级 a4b762a6
......@@ -23,6 +23,13 @@ describe('compiler: transform slot', () => {
`<button><slot name="{{a}}"/></button>`,
`(_ctx, _cache) => {
return { a: _d(_ctx.name) }
}`
)
assert(
`<button><slot :name="'title'+index" :content="{name:'name1'}"></slot></button>`,
`<button><slot name="{{a}}"></slot></button>`,
`(_ctx, _cache) => {
return { a: _d('title' + _ctx.index), b: _r(_d('title' + _ctx.index), { content: { name: 'name1' } }) }
}`
)
})
......
......@@ -53,15 +53,12 @@ export function rewriteSlot(node: SlotOutletNode, context: TransformContext) {
}
if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
if (p.exp) {
p.exp = rewriteExpression(
createCompoundExpression([
context.helperString(DYNAMIC_SLOT) + '(',
p.exp,
')',
]),
context
)
slotName = p.exp
slotName = createCompoundExpression([
context.helperString(DYNAMIC_SLOT) + '(',
p.exp,
')',
])
p.exp = rewriteExpression(slotName, context)
}
} else {
if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册