Last active
February 27, 2018 06:17
-
-
Save ryan-haskell/570fea321dd2a8abfcc4afd8a98f5ffe to your computer and use it in GitHub Desktop.
Vue.js - Props with String Templates
This file contains 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
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' }) |
This file contains 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
<div id="app"> | |
<list /> | |
</div> |
This file contains 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
<!-- 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