console
// 双循环去重
function unique(array) {
// 首先判断传入的处理数据是否为数组
if (!Array.isArray(array)) {
console.log('type error!')
return
}
let result = []
result = array.filter((item, index) => {
return array.findIndex(newitem => newitem.id == item.id) == index
})
return result
}
let list = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 4 }]
console.log(unique(list))
<div class="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="box1">
<div></div>
<div></div>
</div>
.box {
display: flex;
align-items: center;
justify-content: center;
}
.box div {
height: 30px;
width: 9px;
margin-left: 5px;
background: #ff6100;
animation: myMove 1.2s infinite ease-in-out;
border-radius: 10px;
}
.box div:nth-child(2) {
animation-delay: -1.2s;
background: #61000f;
}
.box div:nth-child(3) {
animation-delay: -1.1s;
background: #912333;
}
.box div:nth-child(4) {
animation-delay: -1.0s;
background: #874566;
}
.box div:nth-child(5) {
animation-delay: -0.9s;
background: #345688;
}
@keyframes myMove {
0%,
40%,
100% {
transform: scaleY(0.4);
}
20% {
transform: scaleY(1);
}
}
.box1 {
margin: 50px auto;
width: 50px;
height: 50px;
position: relative;
}
.box1 div {
background: #ff6100;
width: 100%;
height: 100%;
position: absolute;
border-radius: 50%;
animation: mycos 2s infinite ease-in-out;
}
.box1 div:nth-child(2) {
animation-delay: -1s;
opacity: 0.4;
}
@keyframes mycos {
0%,
100% {
transform: scale(0)
}
50% {
transform: scale(1)
}
}