【问题标题】:Vue b-table change one column into linkvue b-table 将一列改成链接
【发布时间】:2021-07-07 01:08:11
【问题描述】:

我对 vue 非常陌生,对于这个项目,我使用 Vue、Bootstrap-vue 来对我的数据 teamList 进行分页。有没有办法可以将 teamList.first_name 更改为链接,以便在用户单击 first_name 值后我可以使用 onSelect or onClick 事件。

JsFiddle 上的代码 = https://jsfiddle.net/ujjumaki/aLdgo7xq/8/

查看

<div class="overflow-auto">
    <b-pagination v-model="currentPage" :total-rows="rows" :per-page="perPage" aria-controls="my-table"></b-pagination>
    <p class="mt-3">Current Page: {{ currentPage }}</p>
    <b-table id="my-table" :items="teamList" :per-page="perPage" :current-page="currentPage" medium selectable>
    </b-table>
</div>

JavaScript

data(){
  return{
    teamList: [
          { id: 5, first_name: 'Pebbles', last_name: 'Flintstone' },
          { id: 6, first_name: 'Bamm Bamm', last_name: 'Rubble' },
          { id: 7, first_name: 'The Great', last_name: 'Gazzoo' },
          { id: 8, first_name: 'Rockhead', last_name: 'Slate' },
          { id: 9, first_name: 'Pearl', last_name: 'Slaghoople' }
    ],
    perPage: 2,
    currentPage: 1
    }
},

计算

computed: {
    rows() {
       return this.teamList.length
    }
},

【问题讨论】:

    标签: twitter-bootstrap vue.js pagination bootstrap-vue


    【解决方案1】:
    <b-table id="my-table" :items="teamList" :per-page="perPage" :current-page="currentPage" medium>
      <template #cell(first_name)="data">
        <a href="#" @click="functionName">{{data.value}}</a>
      </template>
    </b-table>
    

    【讨论】:

    • 这就是我要找的东西谢谢@tauzN
    猜你喜欢
    • 2021-07-09
    • 2020-01-23
    • 2019-01-03
    • 2020-12-17
    • 2019-08-09
    • 2021-09-12
    • 2021-05-13
    • 2019-03-24
    • 2020-08-14
    相关资源
    最近更新 更多