最近在項目中遇到使用 render 函數創建插槽的情景,通過 scopedSlots 屬性實現,使用方法如下:
let table = h('table', {
style: {}
props: {}
scopedSlots: {
// 插槽名
slotDemoName: (scope) => {
return h('button', {
props: {},
on: {
click: () => {
deleteRowData(scope.$index);
}
}
}, '刪除');
}
}
});
網上相關說明較少,特此記錄一下。