2

Well, I am able to display the images properly but it is still giving me javascript errors in console for no reason. Here is my code:

Fetching categories:

fetchCategory: function(){

            this.$http.get('get_category').then(function(response){
                this.$set('categories',response.json());
            });
        }

and here is the table to display the category:

<table class="table table-bordered table-responsive table-striped example1">
    <thead>
        <tr>
            <th>ID</th>
            <th>Category Name</th>
            <th>Icon</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <tr v-for="category in categories">
            <td>@{{ category.id }}</td>
            <td>@{{ category.name }}</td>
            <td><img src="{{url('/')}}/@{{ category.icon }}" width="150px"></td>
            <td>Edit | Delete</td>
        </tr>
    </tbody>
</table>

it displays the images properly, however javascript console still shows 2 404 errors indicating the url of the image GET http://localhost/project/%7B%7B%20category.icon%20%7D%7D 404 (Not Found)

Should I ignore this error? Or is there any other method to include base url in the image path?

2 Answers 2

3

You should bind the src attribute:

<img :src="'{{ url('/') }}/' + category.icon" width="150px">
Sign up to request clarification or add additional context in comments.

Comments

0

Try like this:

<td>{!!HTML::image('path/category.icon')!!}</td>

3 Comments

category is a Vue object, can't be used like that.
But you used in blading and what is the value of category.icon?
category.icon gives a relative path like assets/images/categories/TOOZ6xW8V2JA.jpg It is displaying corretly, but is showing 404 error in console as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.