I use jquery for communication data with api rest.And use vue js for rendering data to my template, but i have error.
[Vue warn]: Error in render function: "TypeError: Cannot read property 'first_name' of undefined"
This my code :
var dashboard = new Vue({
el: '#dashboard',
data:{
profile: {}
}
});
axios.get(url_profile, { headers: {"Authorization": "JWT " + token} })
.then(function(res){
dashboard.$data.profile = res.data;
})
.catch(function(err){
toastr.err(err);
});
Thanks.
https://v2.vuejs.org/v2/guide/instance.html#Data-and-Methods
If you know you'll need a property later, but it starts out empty or non-existent, you'll need to set some initial value. For example:
data: {
newTodoText: '',
visitCount: 0,
hideCompletedTodos: false,
todos: [],
error: null
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.