市北互联平台前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
780 B

<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>