Vue 通過 render 函數動態渲染時使用具名插槽

最近在項目中遇到使用 render 函數創建插槽的情景,通過 scopedSlots 屬性實現,使用方法如下:

let table = h('table', {
    style: {}
    props: {}
    scopedSlots: {
        // 插槽名
        slotDemoName: (scope) => {
            return h('button', {
                props: {},
                on: {
                    click: () => {
                        deleteRowData(scope.$index);
                    }
                }
            }, '刪除');
        }
    }
});

網上相關說明較少,特此記錄一下。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章