<script>
export default {
props:['postId'],
data() {
return {
tasks: [],
id: ''
}
},
created() {
this.id = this.postId,
axios.get('./api/task/' + id) //didn't return result
.then(response => {
this.tasks = response.data
});
},
methods: {
updateId: function (updatedId) {
this.id = updatedId;
}
},
mounted() {
console.log('Component mounted.')
}
}
</script>
API路线
Route::resource('task','Post2Controller');
我正在尝试获取特定的数据行。
错误:
app.js:38012 [Vue警告]:创建的挂钩中出现错误:“ ReferenceError:未定义ID”