欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VUE2.0+ElementUI2.0表格el-table實(shí)現(xiàn)表頭擴(kuò)展el-tooltip

 更新時(shí)間:2018年11月30日 09:58:54   作者:tianqi.zhao  
這篇文章主要介紹了VUE2.0+ElementUI2.0表格el-table實(shí)現(xiàn)表頭擴(kuò)展el-tooltip,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

ElementUI2.0的表格的擴(kuò)展:

elementUI表格table

elementUI文字提示Tooltip

如果要實(shí)現(xiàn)鼠標(biāo)移到表頭有注釋或者彈框該怎么添加呢?

<el-table
  empty-text="正在加載中..."
  :data="contentList"
  style="width: 100%"
  @sort-change="sort"
  class="pro-table-item"
  tooltip-effect="dark"
>
  <template v-for="(item,index) in titleList">
     <el-table-column
      v-if="index == '0'"
      :prop="index.toString()"
      :label="item"
      sortable="custom"
      min-width="120"
      :render-header="renderHeader"
     > 
     </el-table-column>
   <el-table-column
    v-else
    :prop="index.toString()"
      :label="item"
      min-width="120"
      :render-header="renderHeader"
      show-overflow-tooltip
      </el-table-column>
   </template>
</el-table>

注: index == 0 時(shí)是一個(gè)排序功能的按鈕

在使用:render-header之前,首先要 npm i babel-helper-vue-jsx-merge-props babel-plugin-syntax-jsx babel-plugin-transform-vue-jsx --s   安裝一個(gè)解析包,然后在babelrc里配置"plugins": ["transform-runtime", "transform-vue-jsx"]

renderHeader(h, { column }) {
    if(column.label.length>13) {
     return (
       <el-tooltip
        class="item"
        effect="dark"
        content={column.label}
        placement="top"
       >
       <span>{column.label}</span>
       </el-tooltip>
    )
    } else {
     return (
      <span>{column.label}</span>
     )
    }
   },

并不想讓所有的表頭都彈出tooltip,只想讓超出長(zhǎng)度并且

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

隱藏起來(lái)的內(nèi)容在鼠標(biāo)懸浮時(shí)有飄窗,暫時(shí)沒(méi)有更好的辦法,采取的辦法是檢測(cè)表頭內(nèi)容的長(zhǎng)度,不過(guò)這種方式并不能標(biāo)準(zhǔn)的判斷哪一個(gè)表頭需要飄窗。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論