// vue 过滤器
const filters = {
date (v) {
var d = new Date(v);
return d.getFullYear()
+ "-" + ((d.getMonth() + 1)).toString().padStart(2, "0")
+ "-" + (d.getDate()).toString().padStart(2, "0")
+ " " + (d.getHours()).toString().padStart(2, "0")
+ ":" + (d.getMinutes()).toString().padStart(2, "0")
+ ":" + (d.getSeconds()).toString().padStart(2, "0")
},
null (v) {
if (v == null) {
return '--'
} else {
return v
}
},
spaceStr (value) {
return value===null||value===''?'--':value
}
}
// 时间戳
console.log(Date.now())
console.log(filters.date(Date.now()))
console.log(filters.null(2022))
console.log(filters.spaceStr('2022-08-22'))
console.log(filters.spaceStr('2022-08-22'))
console