Skip to content

Instantly share code, notes, and snippets.

@ryan-haskell
Last active February 27, 2018 06:17
Show Gist options
  • Save ryan-haskell/570fea321dd2a8abfcc4afd8a98f5ffe to your computer and use it in GitHub Desktop.
Save ryan-haskell/570fea321dd2a8abfcc4afd8a98f5ffe to your computer and use it in GitHub Desktop.
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