vue3的时间格式化(用过滤器vue3不支持)

一、vue3为什么删除filter(过滤器)

其实原因就是vue3要精简代码,而filter功能重复,filter能实现的功能,用methods和computed方法基本上也可以实现,所以关于filter的vue源代码就被删除了,也更加方便维护。

二、vue2的时间格式化

过滤器写法:https://blog.csdn.net/weixin_54040952/article/details/124804787

三、vue3的时间格式化

js:

在这里插入图片描述

使用方法:
在这里插入图片描述

实现效果:
在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue3中,过滤器已经被删除,因为Vue3的目标是精简代码并提高性能。过滤器的功能可以通过使用methods和computed方法来实现。在Vue2中,可以使用filter来格式化时间,但在Vue3中,可以使用Vueuse库中的useDateFormat函数来实现时间格式化。首先,需要在代码中引入useDateFormat函数。然后,可以在methods中使用useDateFormat函数对需要格式化时间进行处理。例如,可以将请求得到的时间数据赋值给create_time变量,并使用useDateFormat函数对其进行格式化,指定所需的日期格式。最后,可以在模板中显示格式化后的时间。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [vue3之时间显示格式化问题](https://blog.csdn.net/su_yun/article/details/127671682)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [vue过滤器实现日期格式化](https://blog.csdn.net/qq_40951289/article/details/107070737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值