element ui的日期选择器日期格式问题

<el-date-picker  v-model="bannerData.startDate" type="date" placeholder="选择日期" :picker-options="pickerOptions0">

                                </el-date-picker>

js:


bannerData: {

                startDate: '',

                endDate: ''

            }

            

...

console.log(bannerData.startDate);

//Wed Jul 26 2017 00:00:00 GMT+0800 (中国标准时间)

时间格式不是这种 2017-07-26?

怎么解决?


拉莫斯之舞
浏览 400回答 1
1回答

慕的地10843

已在官方文档找到解决方案:加上@change事件,然后赋值setStartDate(val) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(val);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.bannerData.startDate=val;&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; setEndDate(val) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.bannerData.endDate=val;&nbsp; &nbsp; &nbsp; &nbsp; }<el-date-picker @change="setEndDate" v-model="bannerData.endDate" type="date" placeholder="选择日期" :picker-options="pickerOptions0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </el-date-picker>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript