//表头数组
headCols: [
{
label: "开新店人员",
prop: "titile",
visible: true,
},
{
label: "门店经理1",
prop: "titile",
visible: true,
},
{
label: "开新店人员2",
prop: "titile",
visible: true,
},
{
label: "门店经理2",
prop: "titile",
visible: true,
},
],
addtitle:'测试', // 假设后端传的是新的值需要加入表头展示
//触发test事件,如果addtitle不等于空,就组装成一个对象,过滤headCols数组,拿数组和对象比较,如果不相同的就可以放入数组展示
test(){
if (this.addtile) {
var domain = {
label: this.addtile,
prop: "titile",
visible: true,
};
// 过滤表头中如果不相同的label才放入
this.headCols = this.headCols.filter(
(item) => item.label !== domain.label
);
this.headCols.push(domain);
}
},
}