vue 中 获取数据以后,操作DOM
methods:{ getDeliveryProductInfo() { axios.get('/purchase/thirdCash/deliveryMethod/getProduct', { params : { //请求参数 orderId: document.getElementById('orderid').value } }).then(response => { this.tableData = response.data.list; SCF.colSpan.totalColumn(this); }); }, }
main.js
SCF.colSpan = { totalColumn : function(_this){ _this.$nextTick(()=>{ let totalTable = document.getElementsByClassName("el-table__footer-wrapper"); for(let i=0;i<totalTable.length;i++){ let clospan = 1; console.log(document.getElementsByClassName("el-table__footer-wrapper")); let table = document.getElementsByClassName("el-table__footer-wrapper")[i].querySelector("table").querySelectorAll("tr")[0]; let pagis = document.getElementsByClassName("el-table__footer-wrapper")[i].getElementsByTagName("td"); if(pagis[1].querySelector(".cell").innerHTML == ''){ for(let j=1;j<pagis.length;j++){ if(pagis[j].querySelector(".cell").innerHTML == ''){ clospan += 1; }else{ for(let k=clospan-1;k>=1;k--){ table.removeChild(pagis[k]); } pagis[0].setAttribute("colspan", clospan); return ; } } } } }); } } // 声明该公共方法 Vue.prototype.SCF = SCF