1. TaskComponent.vue
<template>
<div>
<button class="btn btn-primary btn-block">Add New Task</button>
<table class="table" v-if="tasks">
<thead>
<tr>
<th>id</th>
<th>Name</th>
<th>Body</th>
</tr>
</thead>
<tbody>
<tr v-for="(task, index) in tasks">
<td>{{index + 1}}</td>
<td>{{task.name}}</td>
<td>{{task.body}}</td>
<td>
<button class="btn btn-info">Edit</button>
</td>
<td>
<button class="btn btn-danger">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
data() {
return {
task: {
name: "",
body: ""
},
tasks: [],
uri: "http://laravelvuecrud.test/tasks/"
};
},
methods: {
loadTasks() {
axios.get(this.uri).then(response => {
this.tasks = response.data.tasks;
});
}
},
mounted() {
this.loadTasks();
}
};
</script>
'라라벨 > laravel vue crud' 카테고리의 다른 글
8. 유효성 검사 (0) | 2020.02.27 |
---|---|
7. Database Modal Create (0) | 2020.02.27 |
5. TaskComponent 템플릿변경 (0) | 2020.02.27 |
4. Vue 설정 component 생성, 등록 (0) | 2020.02.27 |
3. 컨트롤러 설정 Task Json 반환처리, TaskController 작성 (0) | 2020.02.26 |