coderdiaz / vue-datasource

A vue.js component to create dynamic tables
MIT License
417 stars 93 forks source link

Show images in the table #62

Open ericksongmr opened 6 years ago

ericksongmr commented 6 years ago

Hello again, I'm trying to show an image in one of the columns without success, I'm doing it this way:

{
                        name: 'Photo',
                        key: 'photo',
                        render(value) {
                            return `<img src="/storage/uploads/userProduct/18-02-20-10-33-35_photo.png" />`;
                        }
                    },

And try also as the documentation shows but it does not work either:

{
    ...,
    columns: [
        {
            name: 'Name',
            key: 'key',
            render (value, row) {
                return <strong>{value}</strong>
            }
        }
    ]
}

Would you be so kind to help me show the images on the table, how should I do it?

Regards,

coderdiaz commented 6 years ago

At the moment, vue-datasource cannot render html :( but if are you using JSX can you render it

render(value) {
   return <img src={imageUrl} />;
}
ericksongmr commented 6 years ago

Hi, and how can I implement JSX in my project? could you provide me with a link with information please, my project is working with laravel and vue

coderdiaz commented 6 years ago

@ericksongmr you need a plugin for babel https://github.com/vuejs/babel-plugin-transform-vue-jsx

ericksongmr commented 6 years ago

Hi, tell me to do this:

npm install\
  babel-plugin-syntax-jsx\
  babel-plugin-transform-vue-jsx\
  babel-helper-vue-jsx-merge-props\
  babel-preset-env\
  --save-dev

In your .babelrc:

{
  "presets": ["env"],
  "plugins": ["transform-vue-jsx"]
}

Already with that should work? Or do I have to do another type of configuration? Thanks for your time, I'm new to this and I do not know much about the subject.