1.JS实现数组每次只显示5条数据,首尾相连循环显示
getGessListMore(){
this.gessList = [];
let index = 0;
this.gessListIndex+=2
for (let i = this.gessListIndex; i < this.gessListIndex + 5; i++) {
if (this.gessListAll.length - index === this.gessListAll.length - 5) {
let ss = this.gessListAll.splice(0, 5);
this.gessListIndex=0;
for (let j = 0; j < ss.length; j++) {
this.gessListAll.push(ss[j]);
}
}
index = i;
}
for (let i = 0; i < 5; i++) {
this.gessList.push(this.gessListAll[i]);
}
console.log(this.gessListAll,this.gessListIndex)
}
2.iview表格不可以滚动添加类名并添加以下样式
.iviewTable{
/deep/.ivu-table-fixed {
pointer-events: none;
}
/deep/.ivu-table-fixed-header{
pointer-events: all;
}
/deep/.ivu-table-fixed-body {
pointer-events: all;
}
}
3.element树形结构数据过多样式失效
全局样式添加
.el-cascader-panel{
height: 300px;
}
4.获取树形结构当前节点的父节点
//传入参数:需要遍历的arr,需要匹配的末级id 注:id为节点id,columnName 为节点name,children为子节点key,parentId为当前节点的父级id
当前数据 节点id
getParentIdList(data2, nodeId2) {
var arrRes = [];
if (data2.length == 0) {
if (nodeId2) {
arrRes.unshift(data2.areaCode);
}
return arrRes;
}
let rev = (data, nodeId) => {
for (var i = 0, length = data.length; i < length; i++) {
let node = data[i];
//节点id
if (node.areaCode == nodeId) {
arrRes.unshift(node.areaCode);
rev(data2, node.parentId);
break;
} else {
if (node.children) {
rev(node.children, nodeId);
}
}
}
return arrRes;
};
arrRes = rev(data2, nodeId2);
return arrRes;
}