具體效果文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-824475.html
<el-table-column
align="center"
width="100px"
:render-header="(h) =>renderHeader(h,'列名')"
>
<template slot-scope="scope">
<el-switch
v-model="scope.row['列名']"
@change="(value) =>updatePlanStatus(scope.row,'列名',scope.$index,value)"
/>
</template>
</el-table-column>
renderHeader(h, name) {
return h("div", [
h("el-checkbox", {
style: "margin-right:5px",
// 普通的 HTML 屬性
attrs: {
id: "check1"
},
on: {
change: value => {
if (this.selectPoints.length > 0) {
this.$nextTick(() => {
// selectPoints 是選中的列
this.selectPoints.forEach((item, key) => {
item[name] = value;
// 判斷數(shù)組下標(biāo)
const index = this.pointsList.findIndex(
point => item.cabinNo == point.cabinNo
);
// 更新表格數(shù)據(jù)
this.$set(this.pointsList, index, { ...item });
// 上一句執(zhí)行后所有選中的列都會(huì)被清除,需要重新選中
this.$refs.pointTable.toggleRowSelection(
this.pointsList[index],
true
);
});
});
}
}
}
}),
h("span", name)
]);
},
在這里插入代碼片
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-824475.html
到了這里,關(guān)于【el-table 表頭自定義全選列】的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!