数组如何转星期几
可以先创建一个数组利用下标来获取当前是星期几
const WEEK_NAMES = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
每个下标都是对应我们的数组[0,1,2,3,4,5,6]
创建一个新数组来保存我们的值,遍历的数组
item.week = [0,1,2,3,4,5]
let weekNames = [];
item.week.forEach(val => {
weekNames.push(WEEK_NAMES[val])
});
item.weekNames = weekNames;
item.date = weekNames.join(',')//转字符串在页面显示