美文网首页
vue中el-date-picker type=daterang

vue中el-date-picker type=daterang

作者: 小盐_814e | 来源:发表于2020-03-26 17:23 被阅读0次
    <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]]);
            });
          }
    

    相关文章

      网友评论

          本文标题:vue中el-date-picker type=daterang

          本文链接:https://www.haomeiwen.com/subject/pdetuhtx.html