Last active
March 18, 2019 11:52
-
-
Save earth774/ba6975f2a2c42c82d86b5af5946e10e3 to your computer and use it in GitHub Desktop.
Component props loop vue
This file contains hidden or 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
| <!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