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

點擊下載以上學習的所有源碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM