0👍
Looking at the code you have posted, the showImage()
method is not within the methods
object of the Vue instance. Try putting the method into the methods
object and see if that makes a difference.
data: function() {
return {
image: "",
posts: [],
};
},
methods: {
showImage() {
axios.get("test").then(function(response) {
$test = this.posts = response.data.posts;
console.log($test);
}).catch(function(error) {
console.log(error);
});
}
}
- [Vuejs]-Dynamically add a property to an object in an array
- [Vuejs]-Is it possible to add HTML elements in which store some data in Vue?
Source:stackexchange.com