<DatePicker type="datetime" placeholder="请选择..."
:value="eventInfo.happenTime"
format="yyyy-MM-dd HH:mm"
@on-change="handleChange"
:options="pickerOptions" clearable :editable="false"
transfer></DatePicker>
handleChange (date) {
this.eventInfo.happenTime = dataUtils.getExactTimeWithSafari(date);
},
**
**
//兼容苹果浏览器safari的方法
getExactTimeWithSafari: (time) => {
//取得浏览器的userAgent字符串
var userAgent = navigator.userAgent;
//判断是否Safari浏览器
if (userAgent.indexOf("Safari") > -1) {
time = time.replace(/\-/g,"/"); //把'-'转成'/' yyyy/mm/dd
}
var date=new Date(time);
var year=date.getFullYear();
/* 在日期格式中,月份是从0开始的,因此要加0
* 使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
* */
var month= date.getMonth()+1<10 ? "0"+(date.getMonth()+1) : date.getMonth()+1;
var day=date.getDate()<10 ? "0"+date.getDate() : date.getDate();
var hour=date.getHours()<10 ? "0"+date.getHours() : date.getHours();
var minute=date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes();
var second=date.getSeconds()<10 ? "0"+date.getSeconds() : date.getSeconds();
return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
},