我这个也是参考了一些网上的资料整理过来的。
vue:
utils.js:(建立公共JS文件)
//获取周一至周五,到周日的话i=> 5变为7
export const getDataArea = (currentTime) => {
var currentDate = new Date(currentTime)
var timesStamp = currentDate.getTime();
var currenDay = currentDate.getDay();
var dates = [];
for (var i = 0; i < 5; i++) {
dates.push(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/\//g,'-'));
}
return dates
}
使用:
import {getDataArea} from "@/common/utils.js";
在methods方法中调用
bindDrawal(){
var that = this;
//date 你想要传的日期,格式为YYYY-MM-DD
var today = date;
//一周的时间
var weeks = getDataArea(today);
console.log('weeks',weeks);
//筛选日期
var weekToDay = weeks.filter((item)=>{return item == today });
console.log('weekToDay',weekToDay);
console.log('today',today);
}
传统JQ:
//获取周一至周五,到周日的话i=> 5变为7
function getDataArea(currentTime){
var currentDate = new Date(currentTime)
var timesStamp = currentDate.getTime();
var currenDay = currentDate.getDay();
var dates = [];
for (var i = 0; i < 5; i++) {
dates.push(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/\//g,'-'));
}
return dates
}
调用:
$(function(){
//date 你想要传的日期,格式为YYYY-MM-DD
//一周的时间
var weeks = getDataArea(date);
console.log('weeks',weeks);
});
vue微信登录:
vue 微信登录(使用了vant)_余温无痕的博客-CSDN博客
vue+vant商品列表批量倒计时:
vue+vant商品列表批量倒计时_余温无痕的博客-CSDN博客_vant 封装
vue获取微信地址并调用高德地图解析出详细地址:
vue 获取微信定位经纬度,并调用高德地图解析出详细地址_余温无痕的博客-CSDN博客
版权声明:本文为u014678583原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。