Bootstrap-vue 在 b-table 上使用 b-tooltip

Sey*_*eyT 3 api twitter-bootstrap-tooltip vue.js bootstrap-vue

我正在使用 bootstrap-vue 在 b-table 上显示我的数据,我截断了长文本,并使用 title prop 将鼠标悬停在其上时显示原始文本。它与客户 css 配合得很好,但我想使用 b-tooltip

  <b-table hover  sticky-header outlined 
show-empty
      small
      stacked="md"
      :items="apiitems"
      :fields="fields"
      :current-page="currentPage"
      :per-page="perPage"
      :filter="filter"
      :filterIncludedFields="filterOn"
      :sort-by.sync="sortBy"
      :sort-desc.sync="sortDesc"
      :sort-direction="sortDirection"
      @filtered="onFiltered">
   <template v-slot:cell()="data">
        <span :title='data.value'>{{ data.value}}</span>
      </template>
 </b-table>
Run Code Online (Sandbox Code Playgroud)
   fields: [
        { key: 'actions', label: 'Actions' , class: 'truncate1'},
   
         {key: 'key3',     label: 'label 3'    , sortable: true, class: 'truncate1'},
         {key: 'key4',      label: 'lable 4'    , sortable: true, class: 'truncate1'},

         {key: 'keyn',      label: 'lable n'    , sortable: true, class: 'truncate1'},
      ],
Run Code Online (Sandbox Code Playgroud)
    <style>
    .truncate1 {
        max-width: 350px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    </style>
Run Code Online (Sandbox Code Playgroud)

Sey*_*eyT 5

使用 vb-tooltip 指令就像一个魅力。

  <!-- Main table element -->
    <b-table hover  sticky-header outlined
      show-empty
      small
      stacked="md"
      :items="apiitems"
      :fields="fields"
   
    >
  <template v-slot:cell()="data">
        <span v-b-tooltip.hover :title=data.value>{{ data.value}}</span>
      </template>

    
    </b-table>

Run Code Online (Sandbox Code Playgroud)

参考:这里