zoukankan      html  css  js  c++  java
  • 点击提交到列表并删除

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>添加到列表</title>
    <style>
    #app{100%; padding:20px;}
    ul,li,input{padding:0; margin:0;}
    .text{200px; height:30px; padding-left:10px; margin-right: 10px;}
    .button{80px; height:32px;}
    .list{list-style:none; }
    .list li{300px; height:40px; line-height:40px; border-bottom:1px solid #af5b5e;}
    .list li span{float:left;}
    .list li em{float:right;}

    </style>
    </head>
    <body>
    <div id="app">
    <input type="text" class="text" v-model="value" /><input class="button" @click="addValue" type="button" value="提交" />
    <ul class="list">
    <li @click="delValue(index)" :key="index" v-for="(item, index) in list">{{item}}{{index}}</li>
    </ul>
    </div>
    <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
    <script>
    new Vue({
    el:"#app",
    data:{
    value:"",
    list:[],
    index:""
    },
    methods:{
    addValue:function(){
    this.list.push(this.value);
    this.value=""
    },
    delValue:function(index){
    var valLength = this.list.length;
    if(valLength<3){
    this.list.splice(1,index)
    }
    else{
    alert("不能更少了!")
    }
    }
    }
    })
    </script>
    </body>
    </html>

  • 相关阅读:
    git命令使用方法
    git与svn对比
    浏览器缓存原理
    网络性能优化常用方法
    sass/scss 和 less的区别
    AngularJS和ReactJS对比
    让IE6,7,8支持HTML5新标签的方法
    Retina 屏移动设备 1px解决方案
    HttpClient学习
    国家二字码对照表
  • 原文地址:https://www.cnblogs.com/wss198909/p/13937553.html
Copyright © 2011-2022 走看看