on
laravel vue axjos
laravel vue axjos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
< template > < div class = "col-md-8 mt-4" > < div class = "card" > < div class = "card-header" >Task Form < div class = "card-body" > < form action = "./api/task" method = "POST" v-on:submit.prevent = "addTask()" > < div class = "form-group" > < input type = "text" name = "title" v-model = "title" placeholder = "Task title" class = "form-control" > < div class = "form-group" > < input type = "submit" value = "Add Task" class = "btn btn-info" > < script > export default { data(){ return { title: '' } }, mounted() { console .log( 'Component mounted.' ) }, methods:{ addTask(){ axios.post( './api/task' ,{title: 'something' }); alert ( 'Adding Task' ); } } } Colored by Color Scripter
from http://anko3899.tistory.com/249 by ccl(A) rewrite - 2020-04-09 21:01:10