代码拉取完成,页面将自动刷新
同步操作将从 atguigu/vue2.0_base_courseware 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!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>为todolist增加统计总数</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<style>
.completed {
color: green;
text-decoration: line-through;
}
</style>
</head>
<body>
<div id="app">
<div class="panel panel-default ">
<div class="panel-heading ">
<h3 class="panel-title ">{{message}} {{todoCount}}</h3>
</div>
<div class="panel-body ">
<h3>to do list</h3>
<ul class="list-group">
<li class="list-group-item" v-bind:class="{completed:v.completed}" v-for="(v,index) in todos">{{v.title}}
<button @click="toggleState(v)" class="btn btn-xs col-xs-offset-1 pull-right" :class="[v.completed?'btn-success':'btn-danger']">{{v.completed?'未完成':'已完成'}}</button>
<i @click="deleteToDo(index)" class=" glyphicon glyphicon-remove-circle pull-right "></i>
</li>
</ul>
<form v-on:submit.prevent="addNew(newToDo) ">
<div class="form-group ">
<input type="text " class="form-control " id=" " placeholder=" " v-model="newToDo.title ">
</div>
<div class="form-group ">
<button type="submit " class="btn btn-success ">add Todos</button>
</div>
</form>
</div>
<div class="panel-footer ">
</div>
</div>
</div>
<script src="js/vue.min.js "></script>
<script>
new Vue({
el: '#app',
data: {
message: 'hello world',
todos: [{
id: 1,
title: 'learn vue',
completed: true
}, {
id: 2,
title: 'learn wexin',
completed: false
}],
newToDo: {
id: null,
title: '',
completed: false
},
},
methods: {
addNew: function(newToDo) {
this.todos.push(newToDo);
this.newToDo = {
id: null,
title: ''
}
},
deleteToDo(index) {
this.todos.splice(index, 1);
},
toggleState(v) {
v.completed = !v.completed;
}
},
computed: {
//经过处理之后再显示到页面
todoCount() {
return this.todos.length;
}
}
})
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。