<el-date-picker清空格式不正确

在使用element组件的时间选择器时,自带的清楚按钮清空的数据格式不正确,默认是清空为NULL,但是我需要的是空数组.

          <el-date-picker
              v-model="searchTimeData"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="|"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
              style="margin-left: 10px">
          </el-date-picker>

 

 

增加watch及时清除数据为指定格式

  watch: {
    searchTimeData(newValue) {
      if (newValue === null) {
        this.searchTimeData = [];
        console.log('searchTimeData was set to null, resetting to empty array');
      }
    },
    exportTime(newValue) {
      if (newValue === null) {
        this.exportTime = [];
        console.log('searchTimeData was set to null, resetting to empty array');
      }
    }
  },

 

posted @ 2024-08-05 15:22  旺旺大菠萝  阅读(6)  评论(0编辑  收藏  举报