<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>日京的记事本</title>
<script src="/statics/vue.js"></script>
</head>
<body>
<section id="todoapp">
<header>
<h1>日京的记事本</h1>
<input v-model="inputValue" @keyup.enter="add" autofocus="autofocus" autocomplete="off" placeholder="输入">
</header>
<section>
<ul>
<li v-for="(item,index) in list">
<div>
<span>{{index+1}}</span>
<label for="">{{item}}</label>
<button @click="remove(index)">删除</button>
</div>
</li>
</ul>
</section>
<footer>
<span v-show="list.length!=0">
<strong>{{list.length}}</strong>item left
</span>
<button v-show="list.length!=0" @click="clear">清空</button>
</footer>
</section>
<footer>
</footer>
</body>
<script>
var app=new Vue({
el:"#todoapp",
data:{
list:["whj","hhh","xxx"],
inputValue:"加油哦"
},
methods:{
add:function(){
this.list.push(this.inputValue)
},
remove:function(index){
console.log("删除")
console.log(index)
this.list.splice(index,1)
},
clear:function(){
this.list=[];
}
}
})
</script>
</html>
用vue实现一个记事本的功能
最新推荐文章于 2024-05-19 15:23:32 发布