最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序比較兩個數(shù)大小的實現(xiàn)方法

 更新時間:2022年03月24日 09:13:24   作者:底層的渣渣  
最近在工作中遇到一個需求,可以自動對比兩個數(shù)的大小,下面這篇文章主要給大家介紹了關(guān)于微信小程序比較兩個數(shù)大小的實現(xiàn)方法,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下

效果圖

wxml代碼

<!--index.wxml-->
<view class="demo-box">
    <text class="title">請輸入第一個數(shù)字:</text>
    <input type="number" bindchange='num1change'/>
</view>
<view class="demo-box">
    <text class="title">請輸入第二個數(shù)字:</text>
    <input type="number" bindchange='num2change'/>
</view>
<button bindtap='compare'>比較大小</button>
<view class="demo-box">
    <text class="title">比較結(jié)果為:{{result}}</text>
</view>

wxss代碼

/**index.wxss**/
.demo-box{
    margin: 50rpx;
}
input{
    width: 600rpx;
    margin-top: 20rpx;
    border-bottom: 4rpx solid #cccc;
}
button{
    margin: 50rpx;
}
button{
    color: aliceblue;
    background-color: #369;
    letter-spacing: 12rpx;
}

index.js代碼

Page({
  data: { 
      result:''
       },  
    num1:0,//保存一個數(shù)字 
    num2:0,  
    num1change:function(e){           
     this.num1 = Number(e.detail.value)   
     console.log("第一個數(shù)為:"+this.num1) 
     },  
     num2change:function(e){   
     this.num2 = Number(e.detail.value)    
     console.log("第二個數(shù)為"+this.num2)
     },  
     compare:function(e){  
       var str='倆數(shù)相等'  
       if(this.num1 > this.num2){  
       str = '第一個數(shù)大大大大'   
        }else if (this.num1<this.num2){
          str = '第二個數(shù)大大大'
        }    
        this.setData({result:str})  
        },
        })

總結(jié)

到此這篇關(guān)于微信小程序比較兩個數(shù)大小的文章就介紹到這了,更多相關(guān)微信小程序比較數(shù)大小內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

西吉县| 新干县| 安仁县| 上林县| 庄河市| 上蔡县| 汕尾市| 印江| 治县。| 奎屯市| 连州市| 丹江口市| 汝州市| 永善县| 苗栗市| 鄄城县| 黔西县| 饶阳县| 衡阳县| 安吉县| 东山县| 泰安市| 酉阳| 黑山县| 灵璧县| 砀山县| 西吉县| 远安县| 昔阳县| 乾安县| 太原市| 额济纳旗| 临江市| 洮南市| 彭州市| 洪江市| 许昌市| 巴楚县| 衡山县| 普安县| 衡水市|