element UI 中table 部分操作介紹(固定表頭,固定某列,table的thead標題移入提示)


elementUI是常用的前端UI框架之一,下面分享一下其中el-table的用法。

1.固定表頭:

如果表格過長,需要做滾動效果,但是又不想讓表格整體都滾動。那么我們可以做表格頭部固定,內容進行滾動。 

<el-table height="400"> </el-table>

這里的height給值即可,是不是很簡單。解釋:超過高度400,表格的表頭固定不動,內容支持滾動。

 

2.固定某列:

<el-table height="400">

  <el-table-column fixed prop="date" label="日期" width="150"></el-table-column>

 </el-table>

如果仔細的小伙伴就可以看到官方文檔上有介紹,不多做介紹了。仔細看文檔,會發現大部分的問題,文檔上已經說得很清楚了,來,上地址:

https://element.eleme.cn/#/zh-CN/component/table#table-column-scoped-slot 

 

3.el-table 標題中想添加移入效果,如下圖所示:

實現方式有兩種:

第一種:render-header(不報錯,但控制台會給出警告,不推薦此方法實現,見方法二)

html:

<el-table-column prop="remainCounts" label="剩余次數" cell-class-name="col_8" :render-header="renderHeader_date" width="92">

</el-table-column>

js:

renderHeader_date(h, { column, $index }) {

  return [

    '剩余次數',

    h(

      'el-tooltip',

      {

        props: {

          class: 'orderTip',

          content: '剩余所有有效次數',

          placement: 'top',

          effect: 'light'

        },

       },

      [

        h('span', {

          domProps: {

            innerHTML: "<i class='icon iconfont query_icon iconshuoming'></i>"

          }

        })

      ]

    )

  ]

}

 

第二種: slot-scope(推薦)

純html實現: 

<el-table-column prop="remainCounts" label="剩余次數"  cell-class-name="col_8" width="92">
  <template slot="header" slot-scope="{ column, $index }">
    <span>最近到期日</span>
    <el-tooltip class="item" popper-class="orderTip" effect="light" content="剩余所有有效次數" placement="top">
      <span>
        <i class='icon iconfont query_icon iconshuoming'></i>
      </span>
    </el-tooltip>
  </template>
</el-table-column>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM