[bugfix] Stepper: 修复iPad下或修改input高度时输入框样式异常 (#1086)

This commit is contained in:
rex 2018-12-18 14:01:25 +08:00 committed by GitHub
parent 3cb142b8f5
commit 5fe840ad2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 25 deletions

View File

@ -5,7 +5,7 @@
&__minus, &__minus,
&__plus, &__plus,
&__input { &__input-wrapper {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
background-color: @white; background-color: @white;
@ -13,12 +13,12 @@
&__minus, &__minus,
&__plus { &__plus {
position: relative;
width: 40px; width: 40px;
height: 30px; height: 30px;
box-sizing: border-box;
border: 1px solid @border-color;
position: relative;
padding: 5px; padding: 5px;
border: 1px solid @border-color;
box-sizing: border-box;
&::before { &::before {
width: 9px; width: 9px;
@ -32,14 +32,14 @@
&::before, &::before,
&::after { &::after {
content: '';
position: absolute; position: absolute;
margin: auto;
top: 0; top: 0;
left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 0;
margin: auto;
background-color: @gray-darker; background-color: @gray-darker;
content: '';
} }
&:active { &:active {
@ -72,23 +72,32 @@
border-radius: 0 2px 2px 0; border-radius: 0 2px 2px 0;
} }
&__input { &__input-wrapper {
width: 33px; position: relative;
height: 26px; width: 35px;
height: 30px;
padding: 1px; padding: 1px;
min-height: 0; // reset wechat default min height font-size: 14px;
color: @gray-darker;
text-align: center;
border: 1px solid @border-color; border: 1px solid @border-color;
border-width: 1px 0; border-width: 1px 0;
border-radius: 0; border-radius: 0;
box-sizing: content-box; box-sizing: border-box;
color: @gray-darker;
font-size: 14px;
text-align: center;
-webkit-appearance: none;
&--disabled { &--disabled {
color: @gray; color: @gray;
background-color: @background-color; background-color: @background-color;
} }
} }
&__input {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
min-height: 0; // reset wechat default min height
transform: translate3d(-50%, -50%, 0);
appearance: none;
}
} }

View File

@ -50,6 +50,10 @@ VantComponent({
} }
}, },
data: {
focus: false
},
created() { created() {
this.set({ this.set({
value: this.range(this.data.value) value: this.range(this.data.value)
@ -57,6 +61,12 @@ VantComponent({
}, },
methods: { methods: {
onFocus() {
this.setData({
focus: true
});
},
// limit value range // limit value range
range(value) { range(value) {
return Math.max(Math.min(this.data.max, value), this.data.min); return Math.max(Math.min(this.data.max, value), this.data.min);

View File

@ -3,14 +3,17 @@
class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}" class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}"
bind:tap="onMinus" bind:tap="onMinus"
/> />
<view class="input-class van-stepper__input-wrapper {{ disabled || disableInput ? 'van-stepper__input-wrapper--disabled' : '' }}" bindtap="onFocus">
<input <input
type="{{ integer ? 'number' : 'digit' }}" type="{{ integer ? 'number' : 'digit' }}"
class="input-class van-stepper__input {{ disabled || disableInput ? 'van-stepper__input--disabled' : '' }}" class="van-stepper__input"
value="{{ value }}" value="{{ value }}"
focus="{{ focus }}"
disabled="{{ disabled || disableInput }}" disabled="{{ disabled || disableInput }}"
bindinput="onInput" bindinput="onInput"
bind:blur="onBlur" bind:blur="onBlur"
/> />
</view>
<view <view
class="plus-class van-stepper__plus {{ plusDisabled ? 'van-stepper__plus--disabled' : '' }}" class="plus-class van-stepper__plus {{ plusDisabled ? 'van-stepper__plus--disabled' : '' }}"
bind:tap="onPlus" bind:tap="onPlus"