vue中el-date-picker type=daterang

2020-03-26  本文已影响0人  小盐_814e
<el-date-picker
                    unlink-panels
                    style="width:100%;margin-top:5px;"
                    v-model="singleObj.datelist"
                    @input="dateChange"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="出境日期"
                    end-placeholder="入境日期">
              clearable
            </el-date-picker>

赋值方式

if(this.singleObj.beginDate && this.singleObj.endDate){
          let startDate=new Date(this.singleObj.beginDate);
          let endDate=new Date(this.singleObj.endDate);
          // this.singleObj.datelist=""
          this.$set(this.singleObj, "datelist", [
            startDate,
            endDate
          ]);

        }else{
          this.$set(this.singleObj, "datelist", null);

        }

input事件

dateChange(e){
        console.log(e);

        this.$nextTick(() => {
          this.singleObj.datelist = null;
          this.$set(this.singleObj, "datelist", [e[0], e[1]]);
        });
      }
上一篇下一篇

猜你喜欢

热点阅读