前端联调接口
This commit is contained in:
37
Yi.Vue3.x.Vant/src/components/AppCreateTime.vue
Normal file
37
Yi.Vue3.x.Vant/src/components/AppCreateTime.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<span class="subtitle">{{ showTime }}</span>
|
||||
</template>
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from "vue";
|
||||
|
||||
const props = defineProps<{ time: string }>();
|
||||
const showTime = computed(() => {
|
||||
var dataTime=new Date(Date.parse(props.time));
|
||||
const hour:number= getHour(dataTime,new Date())
|
||||
if(hour<=0)
|
||||
{
|
||||
return "刚刚"
|
||||
}
|
||||
if(hour<=6)
|
||||
{
|
||||
return hour+"小时前"
|
||||
}
|
||||
return props.time;
|
||||
|
||||
});
|
||||
const getHour=(s1:Date, s2:Date)=> {
|
||||
var ms = s2.getTime() - s1.getTime();
|
||||
if (ms < 0) return 0;
|
||||
return Math.floor(ms / 1000 / 60 / 60); //小时
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.subtitle{
|
||||
color: #CBCBCB;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user