• 第六课 点击事件调用自定义方法


    <template>
    <!-- 点击事件调用自定义方法 -->

      <div id="app">

          <input type="text" v-model='todo' />

          <button @click="doAdd()">+增加</button>

          <br>

          <hr>

          <br>

          <ul>

            <li v-for="(item,key) in list">

              {{item}}   ----  <button @click="removeData(key)">删除</button>
            </li>
          </ul>


      </div>
    </template>

    <script>

        export default {
          data () {
            return {
              todo:'' ,
              list:[]
            }
          },
          methods:{

            doAdd(){
                //1、获取文本框输入的值   2、把文本框的值push到list里面

                this.list.push(this.todo);

                this.todo='';
            },
            removeData(key){

                // alert(key)

                //splice  js操作数组的方法

                this.list.splice(key,1);
            }
          }

        }
    </script>


    <style lang="scss">



    </style>
  • 相关阅读:
    伪元素:placeholder-shown&&:focus-within
    伪元素:target
    伪元素:focus-within
    MpVue解析
    ESLint在vue中的使用
    vue动态 设置类名
    Java 文件流操作.
    SpringMVC 与 REST.
    基于Nginx和Zookeeper实现Dubbo的分布式服务
    基于Spring的RPC通讯模型.
  • 原文地址:https://www.cnblogs.com/netflix/p/14626499.html
Copyright © 2020-2023  润新知