zoukankan      html  css  js  c++  java
  • 07.计数器

    <style>
            * {
                margin: 0;
                padding: 0;
            }
            
            #app {
                display: flex;
                width: 300px;
                height: 50px;
                background-color: #ccc;
                margin: 50px auto;
                border-radius: 7px;
                box-shadow: 2px 7px 19px 3px rgba(0, 0, 0, .2);
            }
            
            span {
                display: inline-block;
                text-align: center;
                line-height: 50px;
            }
            
            button,
            span {
                flex: 1;
            }
            
            button {
                outline: none;
                border: 0;
                font-size: 20px;
            }
            
            #app button:nth-child(1) {
                border-top-left-radius: 7px;
                border-bottom-left-radius: 7px;
            }
            
            #app .two {
                border-top-right-radius: 7px;
                border-bottom-right-radius: 7px;
            }
        </style>
    <body>
        <div id="app">
            <button @click='add'>+</button>
            <span> {{ num }} </span>
            <button @click='sub' class="two">-</button>
        </div>
        <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></script>
        <script>
            // 创建Vue实例时: el(挂载点) data(数据) methods(方法)
            // 通过this关键字  可以获取data中的数据
    
            var app = new Vue({
                el: '#app',
                data: {
                    num: 1,
                },
                methods: {
                    add: function() {
                        if (this.num < 10) {
                            this.num++;
                        } else {
                            alert('不能再加了哦  到头啦');
    
                        }
                    },
                    sub: function() {
                        if (this.num > 0) {
                            this.num--;
                        } else {
                            alert('别减啦  到底啦');
    
                        }
                    }
                }
            })
        </script>
    </body>
  • 相关阅读:
    iOS身份证号码识别
    GPS定位开发
    Xcode8注释有时会失效的解决方法
    本地缓存FMDB的使用(iOS)
    iOS蓝牙开发
    极光推送
    查找当前数据库服务器中某张表存在于哪个数据库中
    redis安装配置记录
    python 之生成器
    python之迭代
  • 原文地址:https://www.cnblogs.com/yanglaxue/p/14203777.html
Copyright © 2011-2022 走看看