Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (31 sloc) 963 Bytes
<html>
<body>
<div id="app">
<p v-for="todo in todos">
<todoitem :id=todo.id :title=todo.title :completed=todo.completed></todoitem>
</p>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
const ToDoItem = {
template: '<div><input type="checkbox" v-model="completed"/>{{ id }}: {{ title }}</div>',
props: ['id', 'title', 'completed']
}
new Vue({
el: '#app',
data: { todos: [] },
components: {'todoitem': ToDoItem},
mounted() {
this.loadToDos();
},
methods: {
loadToDos() {
fetch('https://jsonplaceholder.typicode.com/todos/')
.then(response => response.json())
.then(json => this.todos = json.slice(0,5))
}
}
})
</script>
</body>
</html>
You can’t perform that action at this time.