Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xNumber支持disabled属性 #3830

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/components/x-number/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</div>
<div class="weui-cell__ft vux-cell-primary" :class="{'vux-number-round': buttonStyle === 'round'}" v-show="!readonly" style="font-size:0">
<div :style="{float:align}">
<a @click="sub" class="vux-number-selector vux-number-selector-sub":class="{'vux-number-disabled':disabledMin}">
<a @click="sub" class="vux-number-selector vux-number-selector-sub":class="{'vux-number-disabled':disabledMin||disabled}">
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18"><defs></defs><path d="M863.74455 544.00086 163.424056 544.00086c-17.664722 0-32.00086-14.336138-32.00086-32.00086s14.336138-32.00086 32.00086-32.00086l700.320495 0c17.695686 0 31.99914 14.336138 31.99914 32.00086S881.440237 544.00086 863.74455 544.00086z"></path></svg>
</a>
<input v-model.number="currentValue" :name="name" class="vux-number-input" :style="{width: width}" :readonly="!fillable" pattern="[0-9]*" type="number" @blur="blur" />
<a @click="add" class="vux-number-selector vux-number-selector-plus" :class="{'vux-number-disabled':disabledMax}">
<input v-model.number="currentValue" :name="name" class="vux-number-input" :style="{width: width}" :readonly="!fillable" :disabled="disabled" pattern="[0-9]*" type="number" @blur="blur" />
<a @click="add" class="vux-number-selector vux-number-selector-plus" :class="{'vux-number-disabled':disabledMax||disabled}">
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20"><defs></defs><path d="M863.328262 481.340895l-317.344013 0.099772L545.984249 162.816826c0-17.664722-14.336138-32.00086-32.00086-32.00086s-31.99914 14.336138-31.99914 32.00086l0 318.400215-322.368714-0.17718c-0.032684 0-0.063647 0-0.096331 0-17.632039 0-31.935493 14.239806-32.00086 31.904529-0.096331 17.664722 14.208843 32.031824 31.871845 32.095471l322.59234 0.17718 0 319.167424c0 17.695686 14.336138 32.00086 31.99914 32.00086s32.00086-14.303454 32.00086-32.00086L545.982529 545.440667l317.087703-0.099772c0.063647 0 0.096331 0 0.127295 0 17.632039 0 31.935493-14.239806 32.00086-31.904529S880.960301 481.404542 863.328262 481.340895z"></path></svg>
</a>
</div>
Expand Down Expand Up @@ -49,6 +49,10 @@ export default {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
width: {
type: String,
default: '50px'
Expand Down Expand Up @@ -103,13 +107,13 @@ export default {
},
methods: {
add () {
if (!this.disabledMax) {
if (!this.disabledMax && !this.disabled) {
const x = new Big(this.currentValue)
this.currentValue = x.plus(this.step) * 1
}
},
sub () {
if (!this.disabledMin) {
if (!this.disabledMin && !this.disabled) {
const x = new Big(this.currentValue)
this.currentValue = x.minus(this.step) * 1
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/x-number/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ props:
default: false
en: if use can fill the number
zh-CN: 是否可填写
disabled:
type: Boolean
default: false
en: Whether the input and button is disabled
zh-CN: 输入框和按钮是否禁用
width:
type: String
default: 50px
Expand All @@ -76,6 +81,11 @@ props:
en: align setting of the selecting area
zh-CN: '按钮部分位置,默认在右边(right),可选值为`left`和`right`'
changes:
v2.11.2:
en:
- '[feature] support prop:`disabled`'
zh-CN:
- '[feature] 支持`disabled`属性'
v2.8.0:
en:
- '[fix] fix on-change fires after created'
Expand Down
6 changes: 6 additions & 0 deletions src/demos/XNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<x-number :value="10" :title="$t('Quantity')" fillable></x-number>
</group>

<group :title="$t('disabled = false')">
<x-number :value="10" :title="$t('Quantity')" disabled></x-number>
</group>

</div>
</template>

Expand All @@ -47,6 +51,8 @@ set value=1, min=-5 and max=8:
zh-CN: 设置值为1,最小值为-5,最大值为8
fillable = true:
zh-CN: 设置可以输入
disabled = false:
zh-CN: 设置输入框和按钮禁用
use with other group elements:
zh-CN: 和其他group子元素一起使用
Switch Component:
Expand Down