效果图
参靠微信小程序:日常记一记
代码
<view v-for="(d,index) in dataList" >
{{getWeekDay(d.ctime)}} //ctime时间格式:2024-06-21 sql:DATE_FORMAT(ctime,'%Y-%m-%d') ctime
</view>
js
export default {
data(){
return {
dataList:[],//时间数组
}
},
onLoad() {
this.loadList();//加载方法
},
methods: {
loadList(){
this.$api.getloadList({ }).then(res => {
//处理返回数据
var dataList= res.data;
})
},
getWeekDay(getDay) {
const now = new Date(getDay);
const weekDay = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
// this.weekDay = weekDay[now.getDay()];
return weekDay[now.getDay()];
}
}
}