下拉框数据去重 vue一进入页面就执行一次的点击事件 tabs切换数据清空

122 阅读1分钟
     // 下拉框数据去重
            // var tempData = res.data.totalList.rows;
            // console.log(tempData,'tempData');
            // var hash = {};
            // tempData = tempData.reduce(function(item, index) {
            //   hash[index.parentname]
            //     ? ""
            //     : (hash[index.parentname] = true && item.push(index));
            //   return item;
            // }, []);
            // //  把后端返回的空值过滤
            // this.productNameList = tempData.filter(r => {
            //   return r.parentname;
            // });
            
            
            
            
            
            
            
            
      <div
      class="spray-search-name-single "
      v-for="(item, index) in nameData"
      :key="item.id"
      :id="'nav' + index"
      v-trigger
      :class="query.parentid == item.deviceId ? 'aa' : 'active'"
      @click="changeTransmissionByPile(item.deviceId)"
    >        
            
            
           methods平级 // 自定义指令 默认是第一个选中
      directives: {
        trigger: {
          inserted(el, binging) {
            el.id == "nav0" ? el.click() : null; // 只点击第一个,id是在循环中手动添加的
          }
        }
      },
      
    <el-tabs v-model="queryParams.queryParam" @tab-click="handleClick">   
       handleClick(tab, event) {
          // tabs切换把数据置空
          this.queryParams.statustypeid = "";
          this.queryParams.onlineStatus = "";
        },