问题代码:
<el-date-picker
v-model="endTime"
type="date"
@change="getTime"
:placeholder="结束时间"
style="width:30%;margin-right:5%"
></el-date-picker>
//输出台显示为
Tue May 07 2019 00:00:00 GMT+0800 (中国标准时间)
但是传输给后台的数据格式需要为 : "yyyy-MM-dd"或者yyyy年MM月dd日
后来找到的解决方法:
//在el-date-picker中加入value-format="yyyy-MM-dd" 属性,意思为当前的时间绑定值得格式为yyyy-MM-dd
//注意有时候写成 format="yyyy-MM-dd" 会不起作用
<el-date-picker
v-model="endTime"
type="date"
value-format="yyyy-MM-dd"
@change="getTime"
:placeholder="结束时间"
style="width:30%;margin-right:5%"
></el-date-picker>
//输出台显示为
2019-05-01
然后!处理很重要!
getTime(date){
this.endTime= date;
console.log(this.endTime);//这个数据就可以直接拿过去传给后台用啦~~
}