干货分享(vue中获取当前时间)vue时间戳,Vue如何实现点击时间获取时间段查询功能,Vue如何实现点击时间获取时间段查询功能,
Vue如何实现点击时间获取时间段查询功能废话不多说,直接上代码。
html:
<template><divclass="personalReport_time"><inputtype="date":max="this.endTime"value=""v-model="startTime"/><div></div><inputtype="date":min="startTime":max="this.maxTime"v-model="endTime"/></div><ulclass="personalReport_date"><li@click="query(today)">今天</li><li@click="query(yesterday)">昨天</li><li@click="query(weeks)">本周</li><li@click="query(lastWeek)">上周</li><li@click="query(month)">本月</li><li@click="query(lastMonth)">上月</li></ul><div><button@click="query"class="but">查询</button></div></template>
vue.js点击事件代码:
//获取时间、//时间解析;Time:function(now){let year=newDate(now).getFullYear();let month=newDate(now).getMonth()+1;let date=newDate(now).getDate();if(month <10) month ="0"+ month;if(date <10) date ="0"+ date;return year+"-"+month+"-"+date
},//本周第一天;
showWeekFirstDay:function(){letNowdate=newDate();letWeekFirstDay=newDate(Nowdate-(Nowdate.getDay()-1)*86400000);letM=Number(WeekFirstDay.getMonth())+1;if(M<10){M="0"+M;}letD=WeekFirstDay.getDate();if(D<10){D="0"+D;}returnWeekFirstDay.getFullYear()+"-"+M+"-"+D;},//本周最后一天
showWeekLastDay:function(){letNowdate=newDate();letWeekFirstDay=newDate(Nowdate-(Nowdate.getDay()-1)*86400000);letWeekLastDay=newDate((WeekFirstDay/1000+6*86400)*1000);letM=Number(WeekLastDay.getMonth())+1;if(M<10){M="0"+M;}letD=WeekLastDay.getDate();if(D<10){D="0"+D;}returnWeekLastDay.getFullYear()+"-"+M+"-"+D;},//获得某月的天数:
getMonthDays:function(myMonth){let monthStartDate =newDate(newDate().getFullYear(), myMonth,1);let monthEndDate =newDate(newDate().getFullYear(), myMonth +1,1);let days =(monthEndDate - monthStartDate)/(1000*60*60*24);return days;},//点击事件
query:function(way){let self=this;this.$refs.pag.currentPage=1;this.page=this.$refs.pag.currentPage;switch(way){casetoday:this.startTime=this.maxTime;this.endTime=this.maxTime;break;caseyesterday:this.startTime=this.Time(newDate().getTime()-24*60*60*1000);this.endTime=this.Time(newDate().getTime()-24*60*60*1000);break;caseweeks:this.startTime=this.showWeekFirstDay();this.endTime=this.maxTime;break;caselastWeek:this.startTime=this.Time(newDate(newDate().getFullYear(),newDate().getMonth(),newDate().getDate()-newDate().getDay()-6));this.endTime=this.Time(newDate(newDate().getFullYear(),newDate().getMonth(),newDate().getDate()+(6-newDate().getDay()-6)));break;casemonth:this.startTime=this.Time(newDate(newDate().getFullYear(),newDate().getMonth(),1));this.endTime=this.maxTime;break;caselastMonth:this.startTime=this.Time(newDate(newDate().getFullYear(),newDate().getMonth()-1,1));this.endTime=this.Time(newDate(newDate().getFullYear(),newDate().getMonth()-1,this.getMonthDays(newDate().getMonth()-1)));break;}this.$axios({
method:post,
url:/inter/user/queryMemberReport,
data:{account:this.account,baseLotteryId:this.lottersId,startTime:this.startTime,endTime:this.endTime
}}).then(function(data){// console.log(data)}).catch(function(error){
console.log(error);})}
这样一个点击查询时间段效果就可以实现了。希望能够帮助到大家。
(window.slotbydup = window.slotbydup || []).push({
id: "u6835052",
container: "_96bek913mdb",
async: true
});
本文链接:http://blog.sauo.top/?id=523 感谢分享!