需求是做个类似于超级课程表那种格子,返回的数组如下,有什么好的思路嘛,弄得我头都大了😭
"schedule":[
[[{"place": "8-503", "name": "形势与政策", "time": "8:30 ~ 10:05", "color": "blue", "section": 2, "weeks_text": "8", "weeks_arr": [8], "teacher": "潘晶晶"}], [{"place": "8-501", "name": "思政课实践教学", "time": "10:25 ~ 12:00", "color": "purple", "section": 2, "weeks_text": "7,13", "weeks_arr": [7, 13], "teacher": "周红禄"}, {"place": "8-505", "name": "毛泽东思想和中国特色社会主义理论体系概论", "time": "10:25 ~ 12:00", "color": "purple", "section": 2, "weeks_text": "1-6,8-12,14-18", "weeks_arr": [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18], "teacher": "周红禄"}], [{"place": "4-402", "name": "大学生职业发展与就业指导", "time": "14:40 ~ 16:15", "color": "red", "section": 2, "weeks_text": "1-4", "weeks_arr": [1, 2, 3, 4], "teacher": "朱玲梅"}], [], []],
[[], [{"place": "9-202", "name": "Android开发技术", "time": "10:25 ~ 12:00", "color": "green", "section": 2, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "段汝林"}], [], [], []],
[[{"place": "8-506", "name": "UI设计及应用", "time": "8:30 ~ 12:00", "color": "purple", "section": 4, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "陈萍"}], [], [{"place": "8-306", "name": "数据库应用技术", "time": "14:40 ~ 17:15", "color": "yellow", "section": 3, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "张晓健"}], [], []],
[[], [{"place": "9-202", "name": "Java Web开发技术", "time": "10:25 ~ 12:00", "color": "blue", "section": 2, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "段汝林"}], [{"place": "9-202", "name": "Android开发技术", "time": "14:40 ~ 16:15", "color": "purple", "section": 2, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "段汝林"}], [{"place": "8-503", "name": "形势与政策", "time": "16:30 ~ 18:05", "color": "red", "section": 2, "weeks_text": "10", "weeks_arr": [10], "teacher": "卓泽楼"}], []],
[[{"place": "9-202", "name": "Java Web开发技术", "time": "8:30 ~ 10:05", "color": "red", "section": 2, "weeks_text": "1-19", "weeks_arr": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "teacher": "段汝林"}], [], [], [], []],
[[], [], [], [], []],
[[], [], [], [], []]
]
建议对数据进行预处理,处理成模板想要的数据,这样模板只负责渲染,不要做复杂的逻辑判断
可以看看我的小程序的实现,不过写的不是很好
https://github.com/WindrunnerMax/SHST/blob/dev/SHST-UNI/pages/study/time-table/time-table.vue
问你同事