vuetable-2 icon indicating copy to clipboard operation
vuetable-2 copied to clipboard

How to render image in vue-table

Open benzsamator opened this issue 7 years ago • 7 comments

It possible to render image in row ?

Please advice me. Thank a lot.

benzsamator avatar May 31 '17 17:05 benzsamator

You can easily achieve this with scoped slots http://jsfiddle.net/z11fe07p/2029/

 <template slot="image" scope="props">
   <img src="https://cdn.auth0.com/blog/vuejs/vue-logo.png" alt="" width="50" height="50">
 </template>

fields: ['__slot:image']

In a real scenario you would have the image links in the json response from the server and you would reference the image something like this :src="props.rowData.imageLink"

cristijora avatar Jun 01 '17 11:06 cristijora

@cristijora Thanks for your answer, It works !!

benzsamator avatar Jun 01 '17 13:06 benzsamator

@cristijora But how to render if image link inside row??? image

Where could i get this link on photo???

     <template slot="image" scope="props">
        <div class="img-circle img-circle--size" v-bind:style="{backgroundImage: 'url(' + 'THERE IS URL OF PHOTO' + ')', backgroundSize: 'cover', backgroundPosition: 'center' }"></div>
      </template>

paladosss avatar Oct 17 '17 06:10 paladosss

@paladosss Go once again through https://vuejs.org/v2/guide/components.html#Scoped-Slots so you can understand better. In your case:

<template slot="image" scope="props">
        <div class="img-circle img-circle--size" v-bind:style="{backgroundImage: `url(${props.rowData.photo})`, backgroundSize: 'cover', backgroundPosition: 'center' }"></div>
      </template>

cristijora avatar Oct 17 '17 06:10 cristijora

@cristijora Thank you very much! <3

paladosss avatar Oct 17 '17 06:10 paladosss

what if the images are from database?

Ajmal-Hossain avatar Sep 26 '19 11:09 Ajmal-Hossain

i tried but i am getting only url but i want to display image ???

shakirayoub123 avatar Apr 04 '23 08:04 shakirayoub123