Vue小项目01——标签记录器

Vue小项目——标签记录器

功能:用户在文本框里输入文本,按回车键,文本添加到信息栏里,并清空文本框里的内容,最左侧有信息编号,下方有所以信息条数,每条信息右测有删除叉,最下方有全部清空按钮,当信息全部清空,最下方一栏将隐藏。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js" integrity="sha384-t1tHLsbM7bYMJCXlhr0//00jSs7ZhsAhxgm191xFsyzvieTMCbUWKMhFg9I6ci8q" crossorigin="anonymous"></script>

<style>
    body{
        padding:0;
        margin: 0;
    }
    .divcenter{
        position: absolute;
        top: 50%;
        left: 50%;
       transform: translate(-50%,-50%);
       width: 500px;
       height: 50%; 
    }
    p{
        border: solid 1px;
        margin: 0px;
        padding: 0px;
    }
    .spanX{
        float:right;
        margin-right: 10px; 
        width: 10px;  
       
    }
    span{
        cursor: pointer; 
    }
    h2{
       text-align: center;
    }

</style>
</head>
<body>
<div id="app" class="divcenter">
    <h2>标签记录器</h2>
    <div>
 <input type="text" placeholder="请输入相应信息后按回车键!" v-model="text" @keyup.Enter="info" style="width: 100%;height: 40px;">
 </div>

 <div>
     <p v-for="(list,index) in arr">
         <span style="background-color: blanchedalmond;"> {{index+1}} </span> {{list}}
         <span class="spanX"  @click="del(index)">x</span>
    </p>

    <div style="border: solid 1px;" v-show="arr.length!=0">
        <span>总数:{{arr.length}}</span>
        <span  style="float: right;" @click="delAll">Clear</span>
    </div>
    
</div>

</div>

<script>
    var app=new Vue({
        el:"#app",
        data:{
           arr:[],
           text:"",
        },
        methods:{
           info:function(){
            this.arr.push(this.text);
            this.text="";
           },
           del:function(index){
          this.arr.splice(index,1);
        } ,
        delAll:function(){
            this.arr=[];
        }

        }      
    })  
</script>
  
</body>
</html>
posted @   永恒之月TEL  阅读(32)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开
  1. 1 Welcome Home REOL
  2. 2 Everywhere We Go REOL
  3. 3 凄美地 REOL
  4. 4 最后一页 REOL
Welcome Home - REOL
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Benjamin Cooper

作曲 : Benjamin Cooper

Sleep don't visit, so I choke on sun

And the days blur into one

And the backs of my eyes hum with things I've never done

Sheets are swaying from an old clothesline

[01:08.0]Like a row of captured ghosts over old dead grass

Was never much but we made the most

Was never much but we made the most

Welcome home

Ships are launching from my chest

Ships are launching from my chest

Some have names but most do not

Some have names but most do not

you find If one, please let me know what piece I've lost

Heal the scars from off my back

I don't need them anymore

I don't need them anymore

You can throw them out or keep them in your mason jars

I've come home

I've come home

All my nightmares escaped my head

All my nightmares escaped my head

Bar the door, please don't let them in

Bar the door, please don't let them in

You were never supposed to leave

You were never supposed to leave

Now my head's splitting at the seams

Now my head's splitting at the seams

And I don't know if I can

And I don't know if I can

Here, beneath my lungs

Here, beneath my lungs

I feel your thumbs press into my skin again