Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e49aaf2

Browse files
ListItem Component and Item Component, and Get Items with axios
1 parent ba6ad91 commit e49aaf2

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

‎package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11+
"axios": "^0.19.2",
1112
"bootstrap-vue": "^2.10.1",
1213
"core-js": "^3.6.4",
1314
"vue": "^2.6.11",

‎src/components/List.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div class="row">
3+
<div class="col-8 mx-auto">
4+
<b-list-group v-bind:key="item.id" v-for="item in items">
5+
<ListItem v-bind:data="item"></ListItem>
6+
</b-list-group>
7+
</div>
8+
</div>
9+
</template>
10+
11+
<script>
12+
import axios from "axios";
13+
14+
import ListItem from "@/components/ListItem.vue";
15+
16+
export default {
17+
name: "List",
18+
data() {
19+
return {
20+
items: []
21+
};
22+
},
23+
components: {
24+
ListItem
25+
},
26+
created() {
27+
axios
28+
.get("https://jsonplaceholder.typicode.com/todos?_limit=5")
29+
.then(res => (this.items = res.data))
30+
.catch(err => console.log(err));
31+
}
32+
};
33+
</script>
34+
35+
<style scoped>
36+
</style>

‎src/components/ListItem.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<b-list-group-item button>{{data.title}}</b-list-group-item>
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: "ListItem",
8+
props: {
9+
data: {
10+
id: String,
11+
title: String
12+
}
13+
}
14+
};
15+
</script>
16+
17+
<style scoped>
18+
</style>

‎src/views/Home.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<template>
22
<div class="col-12">
3-
<h1>{{title}}</h1>
3+
<h3 class="m-2">{{title}}</h3>
4+
<List />
45
</div>
56
</template>
67

78
<script>
8-
9+
importListfrom"@/components/List"
910
export default {
1011
name: 'Home',
1112
data() {
1213
return {
13-
title: 'This is an home page'
14+
title: 'Notas'
1415
}
1516
},
17+
components: {
18+
List
19+
}
1620
}
1721
</script>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /