Created
August 18, 2019 17:52
-
-
Save NovoManu/e8d448e2b2b1888ff52d55598e466905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<Header listName="My new todo list" /> | |
<main> | |
<TodoList> | |
<TodoRow v-for="todo in todos" :key="todo.id" :todo="todo" /> | |
</TodoList> | |
</main> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { Component, Vue } from 'vue-property-decorator' | |
import { ITodo } from '@/types' | |
import { Api } from '@/api/api' | |
import Header from '@/components/Header.vue' | |
import TodoList from '@/components/TodoList.vue' | |
import TodoCard from '@/components/TodoCard.vue' | |
import TodoRow from '@/components/TodoRow.vue' | |
@Component({ | |
components: { Header, TodoList, TodoCard, TodoRow } | |
}) | |
export default class Home extends Vue { | |
todos: ITodo[] = [] | |
async mounted() { | |
this.todos = await this.fetchTodos() | |
} | |
async fetchTodos(): Promise<ITodo[]> { | |
const api = new Api() | |
return await api.fetch('todos') | |
} | |
} | |
</script> | |
<style lang="scss"> | |
.container { | |
padding: 1.5rem; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment