vue学习
1.异步请求列表数据展示
categorysArr() {
const max = 8;
const arr = [];
const { categorys } = this;
let smallArr = [];
categorys.forEach((c, index) => {
if (smallArr.length === 0) {
arr.push(smallArr);
}
smallArr.push(c);
if (smallArr.length === max) {
smallArr = [];
}
});
return arr;
}
2.星级评分
stars(){
const scs = []
const {score} = this
const scoreInt = Math.floor(score)
//添加类名ClASS_ON
for(let i = 0; i < scoreInt;i++){
scs.push(ClASS_ON)
}
//添加类名CLASS_HALF
if (score*10 - scoreInt*10 >= 5){
scs.push(CLASS_HALF)
}
//添加类名CLASS_OFF
while (scs.length < 5){
scs.push(CLASS_OFF)
}
return scs
}

浙公网安备 33010602011771号