|
|
|
@ -54,28 +54,36 @@ export default {
|
|
|
|
|
created: function () { |
|
|
|
|
this.show_time() |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
datatime(val) { |
|
|
|
|
clearInterval(this.timeInterval) |
|
|
|
|
this.time = val |
|
|
|
|
this.show_time() |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
mounted: function () {}, |
|
|
|
|
methods: { |
|
|
|
|
show_time: function () { |
|
|
|
|
let that = this |
|
|
|
|
|
|
|
|
|
if (parseInt(this.datatime).length == 13) { |
|
|
|
|
if (parseInt(this.time).length == 13) { |
|
|
|
|
// 毫秒级 |
|
|
|
|
console.log('毫秒') |
|
|
|
|
this.datatime = this.datatime / 1000 |
|
|
|
|
} else if (parseInt(this.datatime).length == 10) { |
|
|
|
|
this.time = this.time / 1000 |
|
|
|
|
} else if (parseInt(this.time).length == 10) { |
|
|
|
|
console.log('秒') |
|
|
|
|
// 秒级 |
|
|
|
|
} else { |
|
|
|
|
// 时间 |
|
|
|
|
console.log('时间') |
|
|
|
|
this.datatime = Date.parse(this.datatime) / 1000 |
|
|
|
|
console.log(this.time) |
|
|
|
|
this.time = Date.parse(this.time) / 1000 |
|
|
|
|
} |
|
|
|
|
console.log(that.time) |
|
|
|
|
|
|
|
|
|
function runTime() { |
|
|
|
|
console.log(that.datatime) |
|
|
|
|
//时间函数 |
|
|
|
|
let intDiff = that.datatime - Date.parse(new Date()) / 1000 //获取数据中的时间戳的时间差; |
|
|
|
|
let intDiff = that.time - Date.parse(new Date()) / 1000 //获取数据中的时间戳的时间差; |
|
|
|
|
let day = 0, |
|
|
|
|
hour = 0, |
|
|
|
|
minute = 0, |
|
|
|
@ -105,7 +113,7 @@ export default {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
runTime() |
|
|
|
|
setInterval(runTime, 1000) |
|
|
|
|
this.timeInterval = setInterval(runTime, 1000) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|