案例演示
代码
<u-number-box v-model="numValue" @change="valChange">
<view slot="minus" class="minus">
<u-icon name="minus" size="12"></u-icon>
</view>
<input slot="input" type="number" class="input" v-model="numValue">
<view slot="plus" class="plus">
<u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
</view>
</u-number-box>
data() {
return {
numValue: 1
}
},
methods: {
valChange(e) {
console.log('当前值为: ' + e.value)
}
}
// 步进器样式start
.minus {
width: 22px;
height: 22px;
border-radius: 50%;
@include flex;
justify-content: center;
align-items: center;
background-color: #ffffff;
border: 1rpx solid #dddddd;
}
.input {
padding: 0 10px;
width: 40rpx;
text-align: center;
color: #000000;
}
.plus {
width: 22px;
height: 22px;
background-color: #304D99;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
}
// 步进器样式end
网址
https://www.uviewui.com/components/numberBox.html