Skip to content

Instantly share code, notes, and snippets.

@earth774
Last active March 18, 2019 11:52
Show Gist options
  • Select an option

  • Save earth774/ba6975f2a2c42c82d86b5af5946e10e3 to your computer and use it in GitHub Desktop.

Select an option

Save earth774/ba6975f2a2c42c82d86b5af5946e10e3 to your computer and use it in GitHub Desktop.
Component props loop vue
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Amiearth</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="components-demo">
<blog-post v-for="post in posts" v-bind:title="post.title">
</blog-post>
</div>
<script>
Vue.component('blog-post', {
props: ['title'],
template: '<h3>{{ title }}</h3>'
})
new Vue({
el: '#components-demo',
data: {
posts: [{
id: 1,
title: 'My journey with Vue'
},
{
id: 2,
title: 'Blogging with Vue'
},
{
id: 3,
title: 'Why Vue is so fun'
}
]
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment