測試的效果
測試的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) ]); }