vue中获取当前时间返回(yyyy-mm-dd)的格式
vue中获取当前时间返回(yyyy-mm-dd)的格式
·
获取当前时间
data() {
return {
value: this.getDate(),
};
},
methods: {
getDate() {
const nowDate = new Date();
const date = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() + 1,
date: nowDate.getDate(),
};
const newmonth = date.month >= 10 ? date.month : "0" + date.month;
const day = date.date >= 10 ? date.date : "0" + date.date;
return date.year + "-" + newmonth + "-" + day;
},
}
更多推荐
已为社区贡献1条内容
所有评论(0)