<el-date-picker
v-model="form.dateTime"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="changeDateTime"
>
changeDateTime(date){
console.log(date)
},
console.log出来的date值是:
但是这不是我想要的格式,办法来啦!!!!
1.安装格式化插件
npm install moment --save
2.全局引入
// 日期格式化
import Moment from 'moment'
//全局挂载
Vue.prototype.moment = Moment
3.页面应用
changeDateTime(date){
this.form.startTime = this.moment(date[0]).format("YYYY-MM-DD HH:mm:ss")
this.form.endTime = this.moment(date[1]).format("YYYY-MM-DD HH:mm:ss")
},
``