type为time类型的vxe-input获取到的值还是带着日期怎么办
时间: 2024-02-28 20:55:03 浏览: 30
如果您使用的是element-plus的vxe-table组件,可以使用formatter函数来格式化显示时间类型的数据。在formatter函数中,可以使用moment.js等日期处理库来将时间类型的数据转换为您需要的格式。
示例代码:
```html
<template>
<vxe-table :data="tableData">
<vxe-table-column type="time" field="time" title="时间" :formatter="formatTime"></vxe-table-column>
</vxe-table>
</template>
<script>
import moment from 'moment';
export default {
data() {
return {
tableData: [
{ time: '13:30:00' },
{ time: '18:45:00' },
{ time: '21:10:00' }
]
}
},
methods: {
formatTime({ cellValue }) {
return moment(cellValue, 'HH:mm:ss').format('hh:mm A');
}
}
}
</script>
```
在上面的示例代码中,我们通过formatter函数将时间格式化为`hh:mm A`格式,其中`HH:mm:ss`是输入的时间格式,`hh:mm A`是我们需要的格式。您可以根据自己的需要修改格式化的方式。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)