vue中elementui自定义表头并且添加事件

需求:

    自定义表格的表头,然后添加一个checkbox 选中的时候,展示所有的,去掉的时候,不展示所有的

    在代码中可以理解为 自定义elementui表格的表头,并且添加事件

渲染是事件

//添加自定义方法  renderProductId
<el-table-column show-overflow-tooltip prop="productId" label="照片关联货号" min-width="200" 
:render-header="renderProductId">

//在渲染表头的时候,会调用此方法,h为createElement的缩写版  添加on.change事件即可
renderProductId(h, {column}) {
    return h('span', [
        h('span', column.label),
        h('el-checkbox',
            {
                style: 'margin-left: 5px;',
                on: {
                    change: this.change
                }
        }),
    ]);
},
change(val) {
    console.log(val);
}

猜你喜欢

转载自my.oschina.net/andyfeng/blog/1814837