Skip to content

Instantly share code, notes, and snippets.

@ryannhg
Last active Feb 27, 2018
Embed
What would you like to do?
Vue.js - Props with String Templates
Vue.component('List', {
template: `
<div class="list">
<item v-for="name in names" v-bind:name="name" />
</div>
`,
data: () => ({
names: [
'Ryan',
'Alexa',
'Jimmy'
]
})
})
Vue.component('Item', {
template: `
<li class="item">{{ name }}</li>
`,
props: [ 'name' ]
})
new Vue({ el: '#app' })
<div id="app">
<list />
</div>
<!-- Final Result -->
<div id="app">
<ul class="list">
<li class="item">Ryan</li>
<li class="item">Alexa</li>
<li class="item">Jimmy</li
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment