首页 > 技术文章 > iview时间默认日期结束时间23:59:59

wssdx 2020-06-11 11:01 原文

<FormItem label="时间:">
                        <DatePicker type="datetimerange" ref="DatePicker" style="width: 280px" v-model="createDate"
                            @on-change="timeChange">
                        </DatePicker>
</FormItem>
 
timeChange(time) {
                if (time.length && time[0] && time[1]) {
                    // 没有选择时间就默认23:59:59
                    if (parseTime(this.createDate[1]).slice(-8) === '00:00:00') {
                        this.createDate[1] = new Date(parseTime(time[1], '{y}-{m}-{d}') + ' 23:59:59')
                    }
                    this.formInline.createDateBegin = parseTime(this.createDate[0]);
                    this.formInline.createDateEnd = parseTime(this.createDate[1]);
                } else {
                    this.formInline.createDateBegin = '';
                    this.formInline.createDateEnd = '';
                }
                this.$refs['DatePicker'].internalValue = this.createDate;
            },

推荐阅读