asimryu

app.vue

Apr 28th, 2021
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <template>
  2. <div class="todoListContainer">
  3. <div class="heading">
  4. <h2 id="title">Todo List</h2>
  5. <add-item-form v-on:reloadlist="getList()" />
  6. </div>
  7. <list-view
  8. :items="items"
  9. v-on:reloadlist="getList()"
  10. />
  11. </div>
  12. </template>
  13. <script>
  14. import addItemForm from "./addItemForm"
  15. import listView from "./listView"
  16. export default {
  17. components: {
  18. addItemForm,
  19. listView
  20. },
  21. data: function () {
  22. return {
  23. items: []
  24. }
  25. },
  26. methods: {
  27. getList () {
  28. axios.get('api/items')
  29. .then(response => {
  30. this.items = response.data
  31. })
  32. .catch( error => {
  33. console.log( error )
  34. })
  35. }
  36. },
  37. created() {
  38. this.getList();
  39. }
  40. }
  41. </script>
  42. <style scoped>
  43. .todoListContainer {
  44. width: 350px;
  45. margin: auto;
  46. }
  47. .heading {
  48. background: #e6e6e6;
  49. padding: 10px;
  50. }
  51. #title {
  52. text-align: center;
  53. }
  54. </style>
  55.  
Advertisement
Add Comment
Please, Sign In to add comment