update Time
This commit is contained in:
parent
7f9ea0dc5e
commit
b8509c593a
1 changed files with 56 additions and 2 deletions
|
@ -1,8 +1,62 @@
|
|||
<template>
|
||||
<span>time</span>
|
||||
<span :class="classes" @click="handleClick">time</span>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-time';
|
||||
|
||||
export default {
|
||||
name: 'Time',
|
||||
props: {
|
||||
time: {
|
||||
type: [String, Number, Date],
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
validator (value) {
|
||||
return oneOf(value, ['relative', 'date', 'datetime']);
|
||||
},
|
||||
default: 'relative'
|
||||
},
|
||||
hash: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
interval: {
|
||||
type: Number,
|
||||
default: 60
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
date: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
{
|
||||
[`${prefixCls}-with-hash`]: this.hash
|
||||
}
|
||||
];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick () {
|
||||
if (this.hash !== '') window.location.hash = this.hash;
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.setTime();
|
||||
this.timer = setInterval(() => {
|
||||
this.setTime();
|
||||
}, 1000 * this.interval);
|
||||
},
|
||||
beforeDestroy () {
|
||||
if (this.timer) clearInterval(this.timer);
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Reference in a new issue