-
-
Save uno-de-piera/d3270f33fe328a0032937d8c39daeb0e 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> | |
<post-component v-for="(post, index) in posts" :key="index"></post-component> | |
</div> | |
</template> | |
<script> | |
import PostComponent from './PostComponent'; | |
export default { | |
name: 'posts-component', | |
components: { | |
PostComponent | |
}, | |
data () { | |
return { | |
posts: [], | |
category: 'Programación' | |
} | |
}, | |
mounted () { | |
axios.get('https://jsonplaceholder.typicode.com/posts') | |
.then(response => response.json()) | |
.then(posts => this.posts = posts) | |
} | |
} | |
</script> |
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> | |
<div class="card" style="width: 18rem;"> | |
<div class="card-body"> | |
<h5 class="card-title">{{ post.title }}</h5> | |
<p class="card-text">{{ post.body }}</p> | |
<a href="/posts" class="btn btn-primary">Go back</a> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'post-component', | |
props: { | |
post: { | |
type: Object | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment