mint-ui 时间选择器 vue
2019-02-25 本文已影响0人
岁末Zzz

默认的时间

点击打开时间选择器

使默认时间变为当前的是时间


在引入的mint-ui里加上 官方文档有 是点击确定按钮的事件

把获取的时间转换成我们需要的yyyy-mm-dd时间(也可以是yyyy-MM-dd hh:mm)


转换时间 的js
export function formatDate (date, fmt) {
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
let str = o[k] + ''
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
}
}
return fmt
}
function padLeftZero (str) {
return ('00' + str).substr(str.length)
}
找个地方放就行

然后引入

再调用
