<el-form-item >
<el-date-picker v-model="cashboxform.StartTime" type="datetime" placeholder="选择开始时间" style="width:100%" @change="dateFormat"></el-date-picker>
</el-form-item>
Element UI 原有的时间格式不符合需求。通过@chang属性。
dateFormat(val){
console.log(val)
var dateTimeFirst = [];
var dateTimeEnd = [];
dateTimeFirst = val.split(" ")[0].split("-");
dateTimeEnd = val.split(" ")[1].split(":");
console.log(dateTimeFirst[0])
console.log(dateTimeFirst[1])
console.log(dateTimeFirst[2])
console.log(dateTimeEnd[0])
console.log(dateTimeEnd[1])
console.log(dateTimeEnd[2])
var dateYear = dateTimeFirst[0];
var dateMonth = dateTimeFirst[1];
var dateDay = dateTimeFirst[2];
var dateHour = dateTimeEnd[0];
var dateMinute = dateTimeEnd[1];
var dateSecond = dateTimeEnd[2];
var dateUTC = Date.UTC(dateYear,dateMonth-1,dateDay,dateHour,dateMinute,dateSecond);
this.cashboxform.StartTime = dateUTC;
},
运行这段代码之后不能正常赋值。表现就是页面卡死。通过console.log() 显示时间在不停的增加。我在没一段代码试了,this.cashboxform.StartTime = dateUTC;这段代码赋值时,就会出现。如何处理?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…