Vue.component('blog-post', {
props: ['title','id'],
template: '<div><span>{{ id }}</span>©<span>{{ title }}</span></div>'
});
new Vue({
el: '#blog-post-demo',
data: {
posts: [
{ id: 1, title: 'My journey with Vue' },
{ id: 2, title: 'Blogging with Vue' },
{ id: 3, title: 'Why Vue is so fun' }
]
}
});
<div id="blog-post-demo">
<blog-post
v-for="post in posts"
v-bind:id="post.id"
v-bind:title="post.title"
></blog-post>
</div>