I'm trying Vue.js out but I am running into a problem. I am following a tutorial over at Laracasts but my v-for isn't working.
HTML:
<div id="root">
<ul>
<li v-for="name in names" v-text="name"></li>
</ul>
<input type="text" v-model="newName">
<button @click="addName">Add Name</button>
</div>
JS:
new Vue({
el: '#root',
data: {
newName: '',
names: ['John', 'Mike']
}
methods: {
addName() {
this.names.push(this.newName);
this.newName = '';
}
}
})
Fiddle: https://jsfiddle.net/4pb1f4uq/
If it helps, the link to the Laracast with episode: https://laracasts.com/series/learn-vue-2-step-by-step/episodes/4?autoplay=true
You are missing the comma after the data
object:
data: {
newName: '',
names: ['John', 'Mike']
}, // comma here