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

news/2024/7/19 13:45:38 标签: html, js, vue, css, html5
htmledit_views">

vue小项目标签记录器">Vue小项目——标签记录器

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

html"><!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>

http://www.niftyadmin.cn/n/1508117.html

相关文章

linux mysql 监听端口被占用_Linux 查询端口被占用命令

linux中如何查看某个端口是否被占用之前查询端口是否被占用一直搞不明白&#xff0c;问了好多人&#xff0c;终于搞懂了&#xff0c;现在总结下&#xff1a;1.netstat -anp |grep 端口号如下&#xff0c;我以3306为例&#xff0c;netstat -anp |grep 3306(此处备注下&am…

axios的使用规范

axios的使用规范 axios在线库&#xff1a;https://unpkg.com/axios/dist/axios.min.js 获取网络请求 get格式 axios.get(地址&#xff1f;keyvalue&key2value2).then(function(response){},function(err){}) //地址为接口地址&#xff0c;key是文档提供&#xff0c;then在请…

crt mysql中文乱码_SecureCRT连接Linux显示Mysql记录中文乱码

一 查看Linux主机系统字符集 echo $LANGen_US.UTF-8二 ssh客户端character encoding默认设置为default&#xff0c;只要改成指定UTF-8即可在终端上显示中文。SecureCRT设置&#xff1a;(在打开会话以后可以直接设置会话选顶)选项(Options)->会话选项(Session Options)->…

centos7 使用systemd 自定义关机前脚本

systemd (centos7) 需求&#xff0c;关机前执行脚本 关机脚本vi /usr/bin/shutdown_cust.sh#!/bin/bashecho "zhengchangguanji" >> /tmp/log.log chmod x /usr/bin/shutdown_cust.sh设置关机执行 vi /lib/systemd/system/cust_shut.service[Unit]Descriptionp…

ES6使用规则和常见使用方法

ES6使用规则和常见使用方法 let命令 let命令与var的区别 let命令作用域只局限于当前代码块 使用let声明的变量作用域不会被提前 在相同的作用域下不能声明相同的变量 for循环体中let的父子作用域 //for循环用let来定义变量 const命令 定义常用 数组的解构赋值 // 传统赋值 let …

Vue实例—— 计算属性(computed)、 watch 状态监听和filter 过滤器

Vue实例—— 计算属性(computed)、 watch 状态监听和filter 过滤器 Vue实例配置对象 选项说明dataVue实例数据对象methods定义Vue实例中的方法components定义子组件computed计算属性filters过滤器 计算属性(computed) 格式&#xff1a;computed:{ 变量(){ 计算表达式} } <p&…

Web 本地存储和Vue本地存储实例

Web 本地存储 Web Storage API 关键对象 window.sessionStorage对象用于区域存储&#xff1b;window.localStorage对象用于本地存储。特点 数据的设置和读取比较方便。容量较大&#xff0c;sessionStorage大约为5MB&#xff0c;localStorage大约为20MB。只能存储字符串&#xf…

gridview 在已有数据的基础上添加数据_「应用界面优化」Winform分页控件录入数据并保存详解...

点击“了解更多”获取DevExpress v20.2完整版下载一般情况下&#xff0c;我们都倾向于使用一个组织比较好的独立界面来录入或者展示相关的数据&#xff0c;这样处理比较规范&#xff0c;也方便显示比较复杂的数据。不过在一些情况下&#xff0c;我们也可能需要直接在GridView表…