请参阅下面的代码,即使提供了插槽名称,目前所有子代都在默认插槽中呈现。
不确定vue createElement函数是否支持命名槽?
@Component({
props:[]
})
export class TestComponent extends Widget{
items:any[];
render(h:any){
const rootcmp = {
template:`<div>
Temp:<slot name="temp"></slot>
Default:<slot></slot>
</div>`
, data:()=>{
return {};
}
}
const cmp = {
template:'<div slot="default">This is child</div>'
, data:()=>{
return {};
}
}
const cmp2 = {
template:'<div slot="temp">This is child</div>'
, data:()=>{
return {};
}
}
return h(rootcmp, [h(cmp), h(cmp2)]);
}
}
当前行为:
<div>
Temp:Default:
<div>This is child</div>
<div>This is child</div>
</div>
预期行为:
<div>
Temp:
<div>This is child</div>
Default:
<div>This is child</div>
</div>
答案 0 :(得分:0)
确定确实可以在您的选项对象中尝试{slot:'slot-name'}