Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Last active May 25, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/d3270f33fe328a0032937d8c39daeb0e to your computer and use it in GitHub Desktop.
Save uno-de-piera/d3270f33fe328a0032937d8c39daeb0e to your computer and use it in GitHub Desktop.
<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>
<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