Issue
Tell me please, how in DATA to write data from the AJAX response? Example:
var example = new Vue({
el: '#example',
data:{
myArr: []
},
created: function () {
$.getJSON('data.json', function(data) {
this.myArr = data;
});
}
});
The problem is that in myArr, the response data is not written. How to solve this? Thank you.
Solution
Can you try this ? Basically this inside the ajax is not exactly the one you would expect.
var example = new Vue({
el: '#example',
data:{
myArr: []
},
created: function () {
var vm = this;
$.getJSON('data.json', function(data) {
vm.myArr = data;
});
}
});
You can also use reactivity setting method $set instead of directly assigning to the vm.myArr : https://v2.vuejs.org/v2/guide/reactivity.html
Answered By - Mihir Bhende Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.