<template>
<view>
发表时间:{{item.add_time | formatDate}}
</view>
</template>
<script>
export default{
filters:{
formatDate(date){
const nDate=new Date(date)
//将不满10的数字自动补0
const year=nDate.getFullYear().toString().padStart(2,0)
const month=nDate.getMonth()
const day=nDate.getDay().toString().padStart(2,0)
return year+'-'+month+'-'+day
}
}
}
</script>
<style>
</style>
Vue中filters过滤时间的用法(一看就会)
最新推荐文章于 2024-04-10 08:50:33 发布