Commit 2b98434e90077cf9c5c3fa7ca089cbea69b7ae7d

Authored by 梁灏
1 parent 8c51d57d

update Time

Showing 2 changed files with 4 additions and 2 deletions   Show diff stats
examples/routers/time.vue
... ... @@ -3,13 +3,15 @@
3 3 <Time :time="1526608921" />
4 4 <Time :time="1652839997" />
5 5 <Time :time="ddd" :interval="1" />
  6 +
  7 +
6 8 </div>
7 9 </template>
8 10 <script>
9 11 export default {
10 12 data () {
11 13 return {
12   - ddd: new Date('2018-04-27 14:23:00')
  14 + ddd: new Date()
13 15 };
14 16 },
15 17 computed: {},
... ...
src/components/time/time.js
... ... @@ -65,7 +65,7 @@ export const getRelativeTime = timeStamp =&gt; {
65 65 let resStr = '';
66 66 const dirStr = IS_EARLY ? '前' : '后';
67 67 // 少于等于59秒
68   - if (diff <= 59) resStr = diff + '秒' + dirStr;
  68 + if (diff <= 59) resStr = parseInt(diff) + '秒' + dirStr;
69 69 // 多于59秒,少于等于59分钟59秒
70 70 else if (diff > 59 && diff <= 3599) resStr = Math.floor(diff / 60) + '分钟' + dirStr;
71 71 // 多于59分钟59秒,少于等于23小时59分钟59秒
... ...