vue学习十一

复制代码
<div id="app11">
        <h3>哞哞俩数计算器</h3>
        <input type="number" v-model="num1">
        <select v-model="chart">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="×">×</option>
            <option value="÷">÷</option>
        </select>
        <input type="number" v-model="num2">
        =
        {{ math }}
    </div>
    <script>
        const app11=new Vue({
            el:'#app11',
            data:{
                num1:0,
                num2:0,
                chart:'+',
                answer:0
            },
            computed:{
                math:{
                    get(){
                        if(this.chart === '+'){
                            return this.num1*1 + this.num2*1
                        }
                        else if(this.chart === '-'){
                            return this.num1 - this.num2
                        }
                        else if(this.chart === '×'){
                            return this.num1 * this.num2
                        }
                        else if(this.char === '÷'){
                            return this.num1 / this.num2
                        }
                    },
                    set(){
                        
                    }
                }
            }
        })
    </script>
复制代码

 

posted @   子过杨梅  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!
点击右上角即可分享
微信分享提示