Last active
February 27, 2018 06:15
-
-
Save ryan-haskell/c164a0dd9e345c65cd60b82625e071ab to your computer and use it in GitHub Desktop.
Vue.js - Props with Inline 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', { | |
data: () => ({ | |
names: [ | |
'Ryan', | |
'Alexa', | |
'Jimmy' | |
] | |
}) | |
}) | |
Vue.component('Item', { | |
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"> | |
<div is="list" inline-template> | |
<ul class="list"> | |
<div is="item" inline-template | |
v-for="name in names" v-bind:name="name"> | |
<li class="item">{{ name }}</li> | |
</div> | |
</ul> | |
</div> | |
</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