<style>
.completed{
text-decoration: line-through;
}
</style>
<body>
<script type="text/javascript" src="js/vue.js" ></script>
<div id="app">
<task-app :list="tasks"></task-app>
</div>
<template id="task-template">
<div>
<h1>
RemindTasks
<span v-show="reminding">({{reminding}})</span>
</h1>
<ul>
<li @click="toopposite(task)" v-bind:class="{'completed':task.completed}" v-for="task in list">
{{task.body}}<strong @click="deltask(task)">X</strong>
</li>
</ul>
</div>
</template>
<script type="text/javascript">
Vue.component('task-app',{
template:"#task-template",
props:['list'],
methods:{
toopposite:function(task){
task.completed = !task.completed;
},
deltask:function(task){
this.list.pop(task);
}
},
computed:{
reminding:function(){
return this.list.filter(function(task){
return !task.completed
}).length;
}
}
})
var app =new Vue({
el:'#app',
data:{
tasks:[
{body:'this is first',completed:false},
{body:'this is second',completed:true},
{body:'this is lase',completed:false}
]
}
})
</script>
</body>