2👍
✅
First, try calling the getRestaurantsbyId
function in the created
method.
function getRestaurantsbyId(id) {
var restaurants = {
"1" : {
"name": "xxxx",
"description": "xxxxxxxxxx",
"address": "xxxxxxxx",
"contact_number": "rttttttttt"
"cover_image": "images/clients/1/xxxxxx.jpeg"
}
};
return restaurants[id];
}
var restaurant_info = new Vue({
el: '#main',
data: {
info: {
cover_image: null
}
},
created: function() {
this.info = getRestaurantsbyId(restaurant_id);
}
})
And in your template, you don’t need to add curly braces when binding to the src
<img :src="info.cover_image" class="respimg" alt="">
Source:stackexchange.com