首页 > 其他分享 >vue学习十一

vue学习十一

时间:2023-11-04 11:12:47浏览次数:35  
标签:十一 vue return num1 num2 chart else 学习

<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>

 

标签:十一,vue,return,num1,num2,chart,else,学习
From: https://www.cnblogs.com/cocotun/p/17809046.html

相关文章