最近在项目中遇到使用 render 函数创建插槽的情景,通过 scopedSlots 属性实现,使用方法如下:
let table = h('table', {
style: {}
props: {}
scopedSlots: {
// 插槽名
slotDemoName: (scope) => {
return h('button', {
props: {},
on: {
click: () => {
deleteRowData(scope.$index);
}
}
}, '删除');
}
}
});
网上相关说明较少,特此记录一下。