父组件传递过来时间戳times 子组件使用

export default {
	name: 'xxx',
	props: {
		times: {
			type: String,
			default: ''
		}
	},
	computed: {
		timesa(){
			return this.dateTimeFormatter(parseInt(this.times))
			//这里是13位,如果获取到的数据是10位,则需要*1000
			//return this.dateTimeFormatter(parseInt(this.times)*1000)
		}
	},
	methods: {
		onClick() {
			this.$emit('click')
		},
		dateTimeFormatter (t) {
		  t = new Date(t).getTime()
		  t = new Date(t)
		  var year = t.getFullYear()
		  var month = (t.getMonth() + 1)
		  month = this.checkAddZone(month)
		 
		  var date = t.getDate()
		  date = this.checkAddZone(date)
		 
		  var hour = t.getHours()
		  hour = this.checkAddZone(hour)
		 
		  var min = t.getMinutes()
		  min = this.checkAddZone(min)
		 
		  var se = t.getSeconds()
		  se = this.checkAddZone(se)
		 
		  return year + '-' + month + '-' + date + ' ' + hour + ':' + min + ':' + se
		},
		checkAddZone (num) {
		  return num<10 ? '0' + num.toString() : num
		}
	}
}