zoukankan      html  css  js  c++  java
  • Vue实现简易计算机

    Vue实现简易计算机

    1. html
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>Vue实现自定义计算器</title>
        <!--    引进Css样式码   -->
        <link rel=stylesheet href="./d-1.css">
    </head>
    
    <body>
        <div id="app">
            <div id="app1">
            <input type="number" v-model.number="num1" />
            <select name="" id="" v-model.number="operator">
                <option value="0">+</option>
                <option value="1">-</option>
                <option value="2">*</option>
                <option value="3">/</option>
            </select>
            <input type="number" v-model.number="num2" />
            <button @click="cal">=</button>
            <strong>{{res}}</strong>
            </div>
        </div>
        <!--    需联网    -->
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
        <!--    引进js代码    -->
        <script src="./d-1.js"></script>
    </body>
    
    </html>
    
    1. javascript
    
    const vm = new Vue({
        el: "#app",
        data() {
            return {
                num1: 0,
                num2: 0,
                operator: 0,
                res: 0
            }
        },
        methods: {
            cal() {
                switch (this.operator) {
                    case 0:
                        this.res = this.num1 + this.num2;
                        break;
                    case 1:
                        this.res = this.num1 - this.num2;
                        break;
                    case 2:
                        this.res = this.num1 * this.num2;
                        break;
                    case 3:
                        this.res = this.num1 / this.num2;
                        break;
                }
            }
        }
    });
    
    
    1. Css
    
    #app{
        100%;
       height: 80%;
       background-color: skyblue;
       position: absolute;
    }
    
    #app1{
       position: relative;
       top: 5%;
       left: 30%;
    }
    
    
  • 相关阅读:
    文件上传
    data.push({name:'a',value:'a'});
    es数据迁移脚本(python)
    es修改数据类型
    SqlServer应用程序的高级Sql注入
    ASP.NET中如何防范SQL注入式攻击
    AJAX.NET框架构建Lookup服务器控件
    asp.net 读写 XML 小结
    Global.asax 文件
    ajaxpro.2.dll 简单应用
  • 原文地址:https://www.cnblogs.com/k-class/p/14058358.html
Copyright © 2011-2022 走看看