vue学习-自动行合并的table

测试的效果

vue学习-自动行合并的table

测试的html源码截图

vue学习-自动行合并的table

v-table在tableGroup.js中定义,以下就render方法,行的所有单元格都在tableGrouper.js中处理

    render:function(h){
let _this = this;
let ths = this.makeDataHead(h);
let trs = []; //所有数据行
if(_this.grouper)//是否初始化了合并器
_this.grouper.makeRowCellInit();//生成行单元格时,需要先初始化一次
for(let i=0;i<this.currentData.length;i++){
let isLastRow = (i>=this.currentData.length-1);//是否最后一行
//生成行的所有单元格
_this.grouper.makeRowCells(h,this.currentData[i],isLastRow,(tds,attr)=>{
trs.push(h('tr',{
attrs: attr,
},tds));
});
}
return h('table',[
h('thead',[
h('tr',ths)
]),
h('tbody',trs)
]);
}

点击下载以上学习的所有源码

上一篇:OCJP(1Z0-851) 模拟题分析(三)over


下一篇:Gulp 新手使用