小編給大家分享一下微信小程序怎么樣實(shí)現(xiàn)MUI數(shù)字輸入框效果,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
微信小程序?qū)崿F(xiàn)MUI數(shù)字輸入框的具體代碼,具體內(nèi)容如下
效果圖
WXML
<view class="tui-content"> <view class="tui-gallery-list">默認(rèn)</view> <view class="tui-gallery-list"> <view class="tui-number-group"> <button class="tui-number-cell" bindtap="nextNum">-</button> <input class="tui-number-cell" type="number" value='{{number}}'></input> <button class="tui-number-cell" bindtap="prevNum">+</button> </view> </view> <view class="tui-gallery-list">限定最小值0,較大值10</view> <view class="tui-gallery-list"> <view class="tui-number-group"> <button class="tui-number-cell" bindtap="nextNum1" disabled='{{disabled1}}'>-</button> <input class="tui-number-cell" type="number" value='{{number1}}'></input> <button class="tui-number-cell" bindtap="prevNum1" disabled='{{disabled2}}'>+</button> </view> </view> </view>
WXSS
.tui-number-group{ display: table; table-layout: fixed; width: 300rpx; text-align: center; border-radius: 6px; border: 1px solid #bbb; overflow: hidden; } .tui-number-cell{ display: table-cell; line-height: 1.7; border-radius: 0; } button::after{ border-bottom: none; border-top: none; border-radius: 0; }
JS
Page({ data: { number: 1, number1: 5, disabled1: false, disabled2: false }, prevNum(){ this.setData({ number: this.data.number + 1 }); }, nextNum(){ this.setData({ number: this.data.number - 1 }); }, prevNum1() { this.setData({ number1: this.data.number1 >= 10 ? 10 : this.data.number1 + 1 , disabled1: this.data.number1 !== 0 ? false : true, disabled2: this.data.number1 !== 10 ? false : true }); }, nextNum1() { this.setData({ number1: this.data.number1 <= 0 ? 0 : this.data.number1 - 1 , disabled1: this.data.number1 !== 0 ? false : true, disabled2: this.data.number1 !== 10 ? false : true }); } })
注意
button組件的邊框和圓角設(shè)置在button::after,需要對(duì)其重置。
以上是“微信小程序怎么樣實(shí)現(xiàn)MUI數(shù)字輸入框效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站欄目:微信小程序怎么樣實(shí)現(xiàn)MUI數(shù)字輸入框效果-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.2m8n56k.cn/article32/dgsepc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、營銷型網(wǎng)站建設(shè)、定制開發(fā)、商城網(wǎng)站、品牌網(wǎng)站制作、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容