欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > vue3 element-plus el-time-picker控制只显示时 分,并且控制可选的开始结束时间

vue3 element-plus el-time-picker控制只显示时 分,并且控制可选的开始结束时间

2025/4/19 16:38:33 来源:https://blog.csdn.net/weixin_43746297/article/details/147309191  浏览:    关键词:vue3 element-plus el-time-picker控制只显示时 分,并且控制可选的开始结束时间

 只显示时分

 控制只显示时分 HH:mm

 控制只显示时分秒 HH:mm:ss

全部代码:
<template><el-time-pickerstyle="width: 220px !important;"v-model="timeValue"format="HH:mm"value-format="HH:mm"/>
</template><script setup>
import {ref} from 'vue';const timeValue = ref('8:00');</script><style scoped>
.el-time-spinner__wrapper:last-child {display: none !important;
}
</style>
效果:
时分 HH:mm /时分秒 HH:mm:ss

控制可选开始结束日期

:disabled-hours="disabledHours"
:disabled-minutes="disabledMinutes"
 全部代码
<template><el-time-pickerstyle="width: 220px !important;"v-model="timeValue"format="HH:mm:"value-format="HH:mm":disabled-hours="disabledHours":disabled-minutes="disabledMinutes"/>
</template><script setup>
import {ref} from 'vue';const timeValue = ref('8:00');const disabledHours = () => {return Array.from({length: 24}, (_, h) => h).filter(h => h < 8 || h > 16);
};const disabledMinutes = (selectedHour) => {if (selectedHour === 16) return [];return [];
};
</script><style scoped>
.el-time-spinner__wrapper:last-child {display: none !important;
}
</style>
 效果:
8点之前16点之后的不可以选择:
const disabledHours = () => {return Array.from({length: 24}, (_, h) => h).filter(h => h < 8 || h > 16);
};

 8点之后16点之前的不可以选择:
const disabledHours = () => {return Array.from({length: 24}, (_, h) => h).filter(h => h > 8 && h < 16);
};

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词