隱藏elementUI的表格擴展列

問題:

使用elementUITable組件,表格嵌套擴展行,不採用elementUI默認的箭頭操作顯示擴展行,使用自定義操作按鈕,表格帶有邊框

解決:

由於不想顯示出來擴展列,所以給擴展列組件el-table-column設置了樣式display:none,但是實際上並沒有解決問題。使用v-show和設置display:none並沒有區別,使用v-if真的解決了,但是擴展行木有了,文檔中也沒有相關配置項。

最後只能’曲線救國‘了,給擴展列組件el-table-column設置width="1",此時看不見擴展列,但是表格邊框會有一個是重疊的,變粗了。 此時配合樣式把擴展列以及擴展列前一個設置class-name="no_border_right",把這兩列的右邊框設置爲0。

<el-table
  v-loading="loading"
  row-key="id"
  :expand-row-keys="expandRowKeys"
  :data="list"
  border
  style="width: 100%"
  class="expand_table"
>
  <el-table-column
    prop="name"
    label="姓名"
    align="center"
    width="120"
  />
  <el-table-column
    prop="telPhone"
    label="手機號碼"
    align="center"
    width="150"
  />
  <el-table-column
    prop="source"
    label="操作"
    align="center"
    width="100"
    class-name="no_border_right"
  >
    <template slot-scope="scope">
      <el-button type="primary" size="mini" @click="detail(scope.row)">詳情</el-button>
    </template>
  </el-table-column>
  <el-table-column class-name="no_border_right" type="expand" width="1">
    <template slot-scope="scope">
      <expandTable :source-data="detailData" :scope="scope" @toggleRow="toggleRow(scope.row)" />
    </template>
  </el-table-column>
</el-table>
.expand_table{
  .no_border_right{
    border-right: 0 none;
  }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章