Hey there! I have some experience with Vue, but this particular issue is really getting to me. What am I missing here?
So, I have an object that I load via an ajax call within the mounted method:
job: {
"title": "value",
"location": {
"name":"HONG KONG"
}
}
When I try to access {{ job.title }}, everything works fine. But when I try to access {{ job.location.name }}, I get an undefined error even though the value still shows up. And when I just try to view {{ job.location }}, I see the json object so it is defined.
It's frustrating because I know it should be simple, but for some reason, I can't figure out why it's not working as expected.
// Adding on
Here's my entire Vue class:
const router = new VueRouter({
mode: 'history',
routes: []
});
const app = new Vue( {
router,
el: '#app',
data: {
job: {}
},
mounted: function () {
var vm = this
jQuery.ajax({
url: 'https://xxx' + this.jobId,
method: 'GET',
success: function (data) {
vm.job = data;
},
error: function (error) {
console.log(error);
}
});
},
computed: {
jobId: function() {
return this.$route.query.gh_jid
}
}
})