• v-model 练习,简易计算器


    <!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>
    </head>
    <body>
        <div id="app">
            <input type="text" name="" id="" v-model:value="n1">
            <select name="" id="" v-model:value="opt">
                <option value="+">+</option>
                <option value="-">-</option>
                <option value="*">*</option>
                <option value="/">/</option>
            </select>
            <input type="text" v-model:value="n2">
            <input type="button" value="=" @click="calc">
            <input type="text" v-model="result"> 
        </div>
    </body>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
         var app= new Vue({
            el:'#app',
            data:{
                n1:0,
                n2:0,
                result:0,
                opt:'+'

            },
            methods:{
                calc(){
                    // var codeStr='prseInt(this.n1)'+this.opt+'prseInt(this.n2)'
                    // this.result=eval(codeStr)
                    
                    switch(this.opt){
                        case'+':
                        this.result=parseInt(this.n1)+parseInt(this.n2)
                        break;
                        case'-':
                        this.result=parseInt(this.n1)-parseInt(this.n2)
                        break;
                        case'*':
                        this.result=parseInt(this.n1)*parseInt(this.n2)
                        break;
                        case'/':
                        this.result=parseInt(this.n1)/parseInt(this.n2)
                        break;

                    }
                
                }
            }
                
        })
    </script>
    </html>
  • 相关阅读:
    OpenCV中OpenMP的使用
    四种简单的图像显著性区域特征提取方法-----AC/HC/LC/FT。
    【编程练习】寻找和为定值的多个数
    【编程练习】正整数分解为几个连续自然数之和
    (视频)《快速创建网站》2.1 在Azure上创建网站及网站运行机制
    OpenCV轮廓检测,计算物体旋转角度
    OpenCV 实现哈哈镜效果
    CUDA Cuts: Fast Graph Cuts on the GPU
    Graph Cut and Its Application in Computer Vision
    OpenCV进行图像相似度对比的几种办法
  • 原文地址:https://www.cnblogs.com/tiandlsd001/p/15250540.html
Copyright © 2020-2023  润新知