本文实例为大家分享了微信小程序实现MUI数字输入框的具体代码,供大家参考,具体内容如下
效果图
WXML
<view class="tui-content"> <view class="tui-gallery-list">默认</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 "_blank" href="http://xiazai.jb51.net/201801/yuanma/Weixinprogram(jb51.net).rar">下载以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。