I am beginner to vue js. I am trying learn step by step things from official vue documentation. I tried to understand component functionality and created following code:
<div id="app">
<table class="table">
<tr>
<td><strong>Name</strong></td>
<td><strong>Email Address</strong></td>
</tr>
<contact-item v-for="item in contacts" v-bind:contact="item" v-bind:key="item.id"></contact-item>
</table>
</div>
and here is the javascript code for displaying row data from component template.
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
Vue.component('contact-item', {
props: ['contact'],
template: '<tr><td>{{ contact.name }}</td><td>{{ contact.email }}</td></tr>'
})
var app = new Vue({
el: '#app',
data: {
contacts: [
{id: 1, name:'John Doe', email:'[email protected]'},
{id: 2, name:'Peter Drunket', email:'[email protected]'},
{id: 3, name:'Mike Benjamin', email:'[email protected]'},
]
}
});
</script>
The problem is data is displaying but not in table. It is displaying right after "app" div.
