I make something new for me and i have problem.. So lets explain little more..
I have Component with name components/HomeComponent.vue
Here is:
HomeComponent.vue
<script>
export default {
name: "HomeComponent",
data() {
posts: [
{ title: "Hello", body: "Some text" },
{ title: "Hello", body: "Some text" },
{ title: "Hello", body: "Some text" },
{ title: "Hello", body: "Some text" }
];
}
};
</script>
and i have my "view" views/Home.vue
Home.vue
<template>
<!-- Blog Entries Column -->
<div class="col-md-8">
<h1 class="my-4">Статии</h1>
<!-- Blog Post -->
<div class="card mb-4" v-for="post in posts">
<div class="card-body">
<h2 class="card-title">{{ post.title }}</h2>
<p class="card-text">{{ post.body }}</p>
<a href="#" class="btn btn-primary">Read More →</a>
</div>
<div class="card-footer text-muted">
Posted on January 1, 2017 by
<a href="#">xxx</a>
</div>
</div>
</div>
</template>
So i want to access posts in my Home.vue and make for loop.. How to do that?
Thanks in advice! :)
<script>
// @ is an alias to /src
import HomeComponent from "@/components/HomeComponent.vue";
export default {
name: "home",
components: {
HomeComponent
},
};
</script>