vue+element-ui)動態設置tabel列的顯示與隱藏

條件指定列的隱藏於顯示,v-show沒有實現,用v-if實現了,雖然vue官網提示:一般來說,v-if 有更高的切換開銷,而 v-show 有更高的初始渲染開銷。因此,如果需要非常頻繁地切換,則使用 v-show 較好;如果在運行時條件很少改變,則使用 v-if 較好。

<el-table-column type="index" label="序號" width="80" align="center"></el-table-column>
<el-table-column prop="workshop" label="車間" align="center" v-if="isshow002"></el-table-column>
<el-table-column prop="workArea" label="工區" align="center" v-if="isshow003"></el-table-column>
 export default{
     data(){
       return {
        isshow002:true,
        isshow003:true
        }
    }
}

 

 let isShowD = this.userName.indexOf('段');
        console.log(isShowD,'isShowD');
        let isShowC = this.userName.indexOf('車間');
        let isShowW = this.userName.indexOf('工區');
         if(isShowD != -1){
          this.isshow = true;
          this.isshow01 = false;
          this.isshow002 = true;
          this.isshow003 = true;
         }
        if(isShowC != -1){
           this.isshow002 = false;
           this.isshow = true;
           this.isshow01 = false;
           this.isshow003 = true;
        }
        if(isShowW != -1){
          this.isshow = false;
          this.isshow01 = true;
          this.isshow002 = false;
           this.isshow003 = false;
        }

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章