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 id="app"> | |
<router-view /> | |
</div> | |
</template> |
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
export interface ITodo { | |
id: number | |
userId: number | |
title: string | |
completed: boolean | |
} |
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 class="header"> | |
<nav class="header-nav" /> | |
<div class="container"> | |
<h1>My todo list</h1> | |
</div> | |
</header> | |
<main> | |
<div class="container"> |
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 :todos="todos" /> | |
</main> | |
</div> | |
</template> | |
<script lang="ts"> |
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 functional> | |
<header class="header"> | |
<nav class="header-nav" /> | |
<div class="container"> | |
<h1>{{ props.listName }}</h1> | |
</div> | |
</header> | |
</template> | |
<style lang="scss" scoped> | |
.header { |
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
export class Api { | |
private baseUrl: string = 'https://jsonplaceholder.typicode.com/' | |
constructor(private url: string) {} | |
async fetch() { | |
const response = await fetch(`${this.baseUrl}${this.url}`) | |
return await response.json() | |
} | |
} |
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 functional> | |
<div class="container"> | |
<div class="todo-list"> | |
<slot /> | |
</div> | |
</div> | |
</template> | |
<style lang="scss" scoped> | |
.todo-list { | |
display: flex; |
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
export class BaseApi { | |
protected baseUrl: string = 'https://jsonplaceholder.typicode.com/' | |
async fetch(url: string): Promise<any> { | |
const response = await fetch(`${this.baseUrl}${url}`) | |
return await response.json() | |
} | |
} |
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
import axios from 'axios' | |
import { BaseApi } from '@/api/baseApi' | |
export class AxiosApi extends BaseApi { | |
constructor() { | |
super() | |
} | |
async fetch(url: string): Promise<any> { | |
const { data } = await axios.get(`${this.baseUrl}${url}`) | |
return data |
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 class="todo-list__row"> | |
<span>{{ todo.id }}: </span> | |
<span :class="{ 'todo-list__row--completed': todo.completed }">{{ | |
todo.title | |
}}</span> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { Component, Vue, Prop } from 'vue-property-decorator' |
OlderNewer