Wednesday, December 5, 2018

Vue: Vue Js starter code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<div>
<input v-model="message">
<p>{{ message }}</p>
</div>

<div>
<span v-bind:title="message">
Hover your mouse over me for a few seconds
to see my dynamically bound title!
</span>
</div>

<div>
<span v-if="seen">Now you see me asdfasdf</span>
</div>


<ol>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
<ol>
<todo-item
v-for="item in groceryList"
v-bind:todo="item"
v-bind:key="item.id"
></todo-item>
</ol>
</div>


<script>

Vue.component('todo-item', {
props: ['todo'],
template: '<li>{{ todo.text }}</li>'
})

new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
message1: 'You loaded this page on ' + new Date().toLocaleString(),
seen: false,
todos: [
{ text: 'Learn JavaScript' },
{ text: 'Learn Vue' },
{ text: 'Build something awesome' }
],
groceryList: [
{ id: 0, text: 'Vegetables' },
{ id: 1, text: 'Cheese' },
{ id: 2, text: 'Whatever else humans are supposed to eat' }
]
}
})

</script>
</body>
</html>