vue学习-自动行合并的table

测试的效果

 测试的html源码截图

 

 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)
        ]);
    }

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

posted @ 2019-02-28 11:21  生命体验之kevin-Y  阅读(1245)  评论(0编辑  收藏  举报