I'm switching from React to Vue and I just can't force my component to update. Here is my code:
<template>
<div>
</div>
</template>
<script>
export default {
name: "Home",
components: {
},
data() {
return {
jobs: []
};
},
mounted() {
this.fetchData();
},
updated(){
console.log('Updated: ' + this.jobs);//cant log this
},
methods: {
async fetchData() {
const response = await fetch('jobs.json');
const data = await response.json();
console.log(data);//json array. This logs fine
this.jobs.push(...data);
}
}
};
</script>
<style scoped>
.first-row {
padding-top: 10%;
}
</style>
I can't invoke update method and thus can't log my data. Any idea why is this happening ?
Aucun commentaire:
Enregistrer un commentaire