data: () => ({
msg: "Welcome to Your Vue.js App",
week: []
}),
created() {
let data = [];
for (let i = 6; i >= 0; i--) {
data.push(this.getWeek(-i));
}
this.week = data;
console.log(this.week);
},
methods: {
getWeek(day) {
var today = new Date();
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
today.setTime(targetday_milliseconds);
var tYear = today.getFullYear();
var tMonth = today.getMonth();
var tDate = today.getDate();
tMonth = this.doHandleMonth(tMonth + 1);
tDate = this.doHandleMonth(tDate);
return tYear + "-" + tMonth + "-" + tDate;
},
doHandleMonth(month) {
var m = month;
if (month.toString().length == 1) {
m = "0" + month;
}
return m;
}
}
以上是编程学习网小编为您介绍的“vuejs获取一周的时间(就是前七天)”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:vuejs获取一周的时间(就是前七天)
基础教程推荐
猜你喜欢
- Ajax回退刷新页面问题的解决办法 2023-01-20
- 微信小程序登录与注册功能的实现详解 2022-08-31
- ES6中async函数与await表达式的基本用法举例 2022-08-30
- jQuery Ajax的readyState和status的区别和使用详解 2023-01-31
- CSS实现 Google Material Design 文本输入框风格(推荐) 2024-03-11
- ie8 body overflow hidden 无效的解决方法 2024-04-02
- vue-cli · Failed to download repo vuejs-templates/webpack: connect ECONNREF 2023-10-08
- mpVue项目构建及配置 2023-10-08
- JS子父窗口互相操作取值赋值的方法介绍 2024-02-10
- CSS属性探秘系列(七):z-index 2023-12-21