一、过滤器 —Filters
二、过滤器基本使用
三、两种过滤器
- 私有过滤器:上面写在filters里的过滤器函数即为私有
- 全局过滤器
如果私有过滤器与全局过滤器名字一致,调用私有过滤器
四、品牌案例
<td>{
{
item.time | dateFormat}}</td>
------------------------------------------------
<script src="https://unpkg.com/[email protected]/dayjs.min.js"></script>
// 声明初始时间的全局过滤器
Vue.filter('dateFormat',function (time) {
// 1.对time进行格式化,得到HH:mm:ss
// 2.把格式化的时间显示在页面
const dtStr = dayjs(time).format('YYYY-MM-DD HH:mm:ss')
return dtStr
})