I have a really simple code. I'm trying to learn Vue by following this tutorial on youtube https://www.youtube.com/watch?v=4deVCNJq3qc
I am stuck at 31:30 with this code:
Vue.component('car-list', {
template:
<ul>
<li v-for="car in cars">{{ car }}</li>
</ul>
})
for some reason it breaks the whole code and when i inspect the page on google chrome i get the error
Uncaught SyntaxError: Unexpected token '<'
screenshot of the error: https://ibb.co/CnzRFtZ
I am using Atom as my editor.
my whole code
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
</head>
<body>
<div id="root">
{{ carzName }}
<br>
<input v-model="newCar" @keyup.enter="addCar">
<button @click="addCar">+ Add</button>
<li v-for="car in cars">
{{ car }}
</li>
<car-list :cars="cars" />
</div>
</body>
</html>
<script>
Vue.component('car-list', {
template:
<ul>
<li v-for="car in cars">{{ car }}</li>
</ul>
})
const app = new Vue({
el: '#root',
component: [
'car-list'
],
data: {
cars: [
'audi',
'bmw',
'mercu'
],
newCar: ''
},
methods: {
addCar: function() {
this.cars.push(this.newCar)
this.newCar = ''
}
},
computed: {
carzName: function() {
if (this.newCar.length > 1) {
return this.newCar + 'y'
}
}
}
})
</script>
Thanks to anyone who is willing to explain me where the problem is at.
<ul>and another after</ul>.Vue.componentmakescomponent: ['car-list'],redundent