vue.js 自动获取当前时间
在我看开发的时候需要获取当前时间
import baseConfig from './BaseConfig'
export function getdate(){
let yy = new Date().getFullYear();
var mm =
new Date().getMonth() < 10
? "0" + (new Date().getMonth() + 1)
: new Date().getMonth() + 1;
var dd =
new Date().getDate() < 10
? "0" + new Date().getDate()
: new Date().getDate();
let hh = new Date().getHours();
let mf =
new Date().getMinutes() < 10
? "0" + new Date().getMinutes()
: new Date().getMinutes();
let ss =
new Date().getSeconds() < 10
? "0" + new Date().getSeconds()
: new Date().getSeconds();
return baseConfig.Date = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
}
这样每次调用这个方法都会获取当前的时间