我的成绩
@@ -50,25 +50,22 @@ export default defineComponent({
type: Array
}
},
- setup() {
+ setup(props) {
const deadLine = ref(4); // 写死的合格线
-
- function filterData(list: any) {
- let mineRank = 0; // 自己的排名
- list.forEach((element: any) => {
- if(element.isme) {
- mineRank = element.rank;
- }
- });
- // 过滤数据
- const newList = list.filter((item: any) => {
- return item.rank <= 3 || item.rank == deadLine.value || item.rank === mineRank || item.rank === mineRank - 1 || item.rank === mineRank + 1;
- })
- return newList;
- }
+ const list = ref(props.list);
+ let mineRank = 0; // 自己的排名
+ list.value!.forEach((element: any) => {
+ if(element.isme) {
+ mineRank = element.rank;
+ }
+ });
+ // 过滤数据
+ const newList = list.value!.filter((item: any) => {
+ return item.rank <= 3 || item.rank == deadLine.value || item.rank === mineRank || item.rank === mineRank - 1 || item.rank === mineRank + 1;
+ })
return {
- filterData,
+ newList,
deadLine,
}
}