filters:{
cdate(val){
if(val.length ==8){
var year = val.substring(0,4);
var month = val.substring(4,6);
var day = val.substring(6,8);
return year + "." + month + "." + day;
}
},
//时间转换
ctime(val){
if(val.length == 6){
var hour = val.substring(0,2);
var minute = val.substring(2,4);
var second = val.substring(4,6);
return hour +":"+ minute;
}
},
},
用法1:
<div>{{ time | ctime }}</div>
用法2:
<div>{{time}}</div>
methods(){
this.dataList = res.body.reservinfo;
//对请求到的数据写个trap加值
this.dataList.forEach(item=>{
this.time = this.$options.filters.cdate(item.reserv_begin_date);
this.begin = this.$options.filters.ctime(item.reserv_begin_time);
this.end = this.$options.filters.ctime(item.reserv_end_time);
item.newpro = date + " " + begin +"-"+ end;
});
}