el-slider实现一个能拖动的时间范围选择器
<template>
<div style="width: 200px">
<el-slider
v-model="workTime"
:step="5"
:max="1435"
:marks="marks"
:format-tooltip="formatTime"
@input="getTime"
>
</el-slider>
</div>
</template>
<script>
export default {
name: 'aaa',
components: {},
props: {},
computed: {},
watch: {},
filters: {},
data() {
return {
workTime: 0,
marks: {
0: '00:00',
720: {
style: {
color: '#1989FA'
},
label: '12:00'
},
1435: {
label: this.$createElement('strong', '23:55')
}
},
}
},
methods: {
/**
* @Event 分钟转成时间(如:06:05)
* params: val(分钟)
* @author: mhf
* @time: 2024-01-31 14:17:54
**/
formatTime(val) {
const hour = Math.floor(val / 60).toString().padStart(2, '0');
const min = (val % 60).toString().padStart(2, '0');
console.log(`${hour}:${min}`)
return `${hour}:${min}`;
},
getTime(e) {
this.formatTime(e)
}
},
created() {
},
mounted() {
},
destroyed() {
}
}
</script>
<style lang="scss" scoped></style>
标签:el,00,val,hour,slider,选择器
From: https://www.cnblogs.com/ProgrammerMao-001/p/18342764