问题: el-time-picker 筛选出某个时间点保存,之后从后台获取该时间,页面显示
`
<el-time-picker class=”my_time_picker_32″ :clearable=”false” v-model=”scope.row.plan[index]” placeholder=” 时间 ” format=”HH:mm”></el-time-picker>
`
解决: 字符串转 date
const _converTime = ac.plan.map((item: any) => {const _arr: string[] = item.split(':');
return new Date(2010, 10, 10, Number(_arr[0]), Number(_arr[1]));
});
附: 选中的时间点过滤出时分
`
private dateConversion(value: any): string {
const d = new Date(value);
let _h = d.getHours() + '';
if (_h.length === 1) {_h = '0' + _h;}
let _m = d.getMinutes() + '';
if (_m.length === 1) {_m = '0' + _m;}
return _h + ':' + _m;
}
`