6 changed files with 125 additions and 15 deletions
@ -0,0 +1,48 @@ |
|||
<template> |
|||
<span>{{ showText }}</span> |
|||
</template> |
|||
|
|||
<script> |
|||
import dateFormat from "dai-js/tools/dateFormat"; |
|||
|
|||
export default { |
|||
name: "dateShow", |
|||
props: { |
|||
format: { |
|||
type: String, |
|||
default: "yyyy-MM-dd hh:mm:ss", |
|||
}, |
|||
timestamp: { |
|||
type: String, |
|||
default: "", |
|||
}, |
|||
}, |
|||
data() { |
|||
return { |
|||
showText: "", |
|||
}; |
|||
}, |
|||
computed: {}, |
|||
watch: { |
|||
timestamp(val) { |
|||
this.computeShowText(); |
|||
}, |
|||
}, |
|||
created() { |
|||
this.init(); |
|||
}, |
|||
methods: { |
|||
init() { |
|||
this.computeShowText(); |
|||
}, |
|||
|
|||
computeShowText() { |
|||
const { timestamp, format } = this; |
|||
if (!timestamp) return; |
|||
const showText = dateFormat(new Date(timestamp * 1000), format); |
|||
|
|||
this.showText = showText; |
|||
}, |
|||
}, |
|||
}; |
|||
</script> |
Loading…
Reference in new issue