网址:https://www.npmjs.com/package/vue2-datepicker 实例:只能选择整点或者半点 1:npm install vue2-datepicker --save 2:在需要使用的页面中
<date-picker :open.sync="open" v-model="BeginTimes" :minute-step="30" :hour-options="hours" :second-step="60"
value-type="format" type="datetime" placeholder="选择日期时间" popup-class=zIndex @change="handleChange1"></date-picker>
<script>
import DatePicker from 'vue2-datepicker';
import 'vue2-datepicker/index.css';
export default {
components: { DatePicker },
data() {
return {
open: false,//控制开关
BeginTimes: "",
hours: Array.from({ length: 24 }).map((_, i) => i),
};
},
methods:{
handleChange1(value, type) {
//点了分钟就关闭
if (type === 'minute') {
this.open = false;
}
},
}
};
</script>