Guest User

Untitled

a guest
Jan 6th, 2019
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.  
  3. <div class="col-md-6" >
  4. <div class="card mt-4">
  5. <div class="card card-default">
  6. <div class="card-header">Task Form</div>
  7.  
  8. <div class="card-body">
  9. <form action="./api/word" method="post" @submit.prevent="addTask()">
  10. <div class="form-group">
  11. <input type="text" name="title" v-model="title" placeholder="Local word" class="form-control">
  12. </div>
  13. <div class="form-group">
  14. <input type="text" name="second_title" v-model="second_title" placeholder="Foreign word" class="form-control">
  15. </div>
  16. <div class="form-group">
  17. <input type="submit" value="Add Task" class="btn btn-info">
  18. </div>
  19. </form>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. data(){
  28. return{
  29. title:'',
  30. second_title:''
  31. }
  32.  
  33. },
  34. mounted() {
  35. console.log('Component mounted.')
  36. },
  37. methods:{
  38. addTask(){
  39.  
  40. Event.$emit('taskCreated',{title:this.title, second_title:this.second_title})
  41.  
  42. axios.post('./api/word', {
  43. title:this.title,
  44. second_title:this.second_title
  45.  
  46.  
  47. })
  48.  
  49. // Event.$emit('taskCreated',{title:this.title, second_title:this.second_title});
  50. // this.title='';
  51. // this.second_title='';
  52. }
  53. }
  54. }
  55. </script>
RAW Paste Data