В настоящее время я учусь vue с laravel. Я делаю простой сайт todo. Я делаю все вещи в welcome.blade.php
. Я могу хранить задачи, но не могу просмотреть все задачи.
Вот что я попробовал
welcome.blade.php
<div class="card-body">
<div class="col-md-12">
<div class="form-group">
<input type="submit" @click.prevent="createTodo()" value="Create">
<input type="text" class="form-control col-md-10" v-model="todo.taskName">
</div>
</div>
<hr>
<div class="content">
@{{ todo }}
</div>
</div>
код Vue
const app = new Vue({
el: '#todo',
data: {
todo: {
taskName: ''
}
},
methods: {
createTodo: function createTodo() {
var _this = this;
var input = this.todo;
axios.post('/create-todo', input).then(function (response) {
_this.todo = {'taskName': ''};
_this.getVueItems();
});
},
getData: function getData(){
axios.get('/').then(function (response) {
this.todo = response.data;
})
}
},
mounted: function () {
this.getData();
}
});
web.php
Route::get('/', function () {
return view('welcome');
});
Route::post('create-todo', 'TodoController@store');
Я запутался в том, как вернуть данные. Потому что /
route напрямую возвращает представление.