Thursday, 20 April 2017

How to add img src attribute with VueJs

In my NodeJs route, I have the following:

router.get('/list/:id', function(req, res, next) {
    request("http://localhost:3000/api/journal/" + req.params.id, function(error, response, body) {
        var json = JSON.parse(body);
        res.render('listdetail', { title: 'Journal', data: json });
    });
});

The data is a json object containing all my screen fields. One of the fields is a base64 presentation of an image.

Then, in my List Detail html I have the following:

<div id="app">
    <img class="materialboxed" src="" width="200">
</div>

This is surely not working... How can I add to the src attribute the base64 information that was sent by NodeJS?

I tried also the following:

<img class="materialboxed" :src=imagebase64Source width="200">
<script type="text/javascript">
    var app = new Vue({
      el: '#app',
      data: {
        imagebase64Source: 
      }

    })
</script>

But it obviously does not work Thanks



via Felipe Caldas

No comments:

Post a Comment