Search code examples
javascripttwitter-bootstrapvue.jsvuejs2bootstrap-vue

Create a link inside vue bootstrap b-table cell


I have a b-table compo

<b-table responsive 
         hover 
         :items="myItems" 
         :fields="myField">

On my items, I return a url from the back-end, so I want to do on my template

<template slot="my-link" slot-scope="data">
    <a href="data.item.link">link</a>
 </template>

The above doesn't work, it renders

<a href="data.item.link">link</a>

Instead of

<a href="https://mylink.com">link</a>

Solution

  • You should bind it using v-bind:href="..." or shortly :href="..." with b-link component :

     <template slot="my-link" slot-scope="data">
        <b-link :href="data.item.link">link</b-link>
    </template>