// 日期切换
determinemonth(value){
let tempTime = value.split('-');
if(tempTime[0] + '' + tempTime[1] == this.$store.state.monthTime.substr(0,6)){
this.timedate = this.$store.state.daytime
}else {
let lastDay = new Date(tempTime[0],tempTime[1],0).getDate();
this.timedate = tempTime[0]+''+tempTime[1]+''+lastDay
}
this.getDataIndex()
},
该方法是iview框架时间控件@change的监听方法,value是控件返回值,格式为(例子:2020-12),所以使用了split()方法切割,返回切割后的数组,再拿来用作于条件判断。
这里因为业务需求,时间规则是“选择当前月的话取当天,历史月份取该月最后一天”。
注:monthTime和daytime均为Vuex里面定义好的值,分别代表当前月(例子:202012)和当前日(例子:20201222)。
本文介绍了一个IView框架中日期控件@change事件的处理方法,详细解释了如何根据用户选择的不同月份来确定具体日期(当前月取当天,历史月份取月末)。通过Vue和Vuex状态管理实现这一功能。
53

被折叠的 条评论
为什么被折叠?



