@params evaluation = 4.2/5.0/0.3 3.1 等等。
commentStart(evaluation){
//分数图片的数组0-10 表示0.1-1分星星图标
let starKu = [
"grade0.png",
"grade1.png",
"grade2.png",
"grade3.png",
"grade4.png",
"grade5.png",
"grade6.png",
"grade7.png",
"grade8.png",
"grade9.png",
"grade10.png"
];
//默认5分
let starList = [
"grade10.png",
"grade10.png",
"grade10.png",
"grade10.png",
"grade10.png"
];
if(!evaluation){
return starList;
}
for (let i = 0;i < 5;i++){
if(evaluation >0 && evaluation<1){
evaluation = evaluation.toFixed(1);
starList[i] = starKu[evaluation*10];
}else if(evaluation < 0){
starList[i]= starKu[0];
}
--evaluation;
}
return starList; //返回分数数组
}
网友评论