vue小黑记事本

<template>
  <div class="home">
    <h1>小黑记事本</h1>
	<input class="el-input" type="text" v-model="input" placeholder="请输入内容" @keyup.enter="add">
	<ul class="L0">
		<li v-for="(item,index) in title" :key="index">
			<span class="l1">{{index+1}} .</span>
			<span>{{item.tit}}</span>
			<button class="l2" @click="shchu"></button>
		</li>
		<div id="one">
			<span>{{title.length}} item left</span>
			<button @click="qk">清空</button>
		</div>
	</ul>
  </div>
</template>
<script>
export default {
  name: 'Home',
  data() {
	return {
		title:[{
			tit:'学习'
		},
		{
			tit:'打篮球'
		},
		{
			tit:'下午似乎要下雨'
		}],
		input: '',
	}
  },
  methods: {
  	add(){
		let arr = this.input
		console.log(arr)
		this.title.push({
			num:1,
			tit:arr
		})
		this.input = ''
  	},
	shchu(a){
		this.title.splice(a,1)
	},
	qk(){
		this.title = []
	}
  },
}
</script>
<style scoped>
*{
	margin: 0px;
	padding: 0px;
	list-style: none;
}
.home h1{
	color: #bd5757;
	text-align: center;
}
.el-input{
	width: 24.5%;
	margin: 0 auto;
	height: 40px;
}
.L0{
	width: 25%;
	margin: 0 auto;
	padding: 0;
}
.L0 li{
	border: 1px solid #ccc;
	height: 40px;
	line-height: 40px;
	position: relative;
}
.L0 li span{
	float: left;
}
.L0 li .l1{
	margin-right: 20px;
}
.L0 li .l2{
	display: none;
	width: 30px;
	height: 30px;
	line-height: 30px;
	font-size: 20px;
	color: #cc9a9a;
	transition: color 0.2s ease-out;
	background: #fff;
	border: 1px solid #fff;
	position: absolute;
	right: 0px;
}
.L0 li .l2:hover{
	color:#af5b5e;
}
.L0 li .l2::after{
	content: 'x';
}
.L0 li:hover .l2 {
	display: block;
}
.L0 li .edit {
	display: none;
}
#one{
	height: 40px;
	border: 1px solid #ccc;
	line-height: 40px;
}
#one span{
	float: left;
}
#one button{
	float: right;
	margin-top: 9px;
}
</style>	
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值