为什么在前端页面显示时,render函数中onchange总是显示出最后一个name变量的值
有人知道吗
var linenamelist=response.data.linenamelist;
for(var i=0;i<linenamelist.length;i++){
var name=linenamelist[i];
console.log(name)
var obj={
title: name,
key:name,
//width:'80',
align:'left',
render: (h, params) => {
return h('checkbox', {
style: {
},
on: {
'on-change': () => {
console.log(name+","+that.listdata[params.index][name])
if(params.row[name]=="1"){
that.listdata[params.index][name]="0";
}else{
that.listdata[params.index][name]="1";
}
}
}
}, '');
}
}
console.log(obj)
that.listcolumns.push(obj);
}