Numberbox
组件类型:UxNumberboxComponentPublicInstance
支持整数、小数步进,可长按快速步进
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
name | String | 标识符,在回调事件中返回 | |
theme | String | 主题颜色 | |
color | String | $ux.Conf.placeholderColor | 颜色 |
darkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
inputColor | String | $ux.Conf.placeholderColor | 输入框背景颜色 |
inputDarkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
fontColor | String | $ux.Conf.placeholderColor | 输入框背景颜色 |
fontDarkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
value | Number | 值 | |
min | Number | 0 | 最小值 |
max | Number | 999999999 | 最大值 |
step | Number | 1 | 步长 |
decimal | Boolean | 允许输入小数默认false) | |
precision | Number | 1 | 小数点精度 |
width | Any | 50 | 输入框宽度 |
radius | Boolean | false | 圆角按钮 |
minus | Boolean | true | 显示-按钮 |
plus | Boolean | true | 显示+按钮 |
longpress | Boolean | true | 开启长按加减手势 |
disablePlus | Boolean | false | 禁用+ |
disableMinus | Boolean | false | 禁用- |
disabled | Boolean | false | 禁用 |
margin | Array | 边距[上右下左][上下左右][上下左右] | |
mt | Any | 距上单位px | |
mr | Any | 距右单位px | |
mb | Any | 距下单位px | |
ml | Any | 距左单位px | |
padding | Array | 填充[上右下左][上下左右][上下左右] | |
pt | Any | 上内边距单位px | |
pr | Any | 右内边距单位px | |
pb | Any | 下内边距单位px | |
pl | Any | 左内边距单位px | |
xstyle | Array | 自定义样式 |
theme
值 | 说明 |
---|---|
primary | 主色 |
warning | 警告 |
success | 成功 |
error | 错误 |
info | 文本 |
darkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
inputDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
fontDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
decimal
值 | 说明 |
---|---|
true | |
false |
radius
值 | 说明 |
---|---|
true | |
false |
minus
值 | 说明 |
---|---|
true | |
false |
plus
值 | 说明 |
---|---|
true | |
false |
longpress
值 | 说明 |
---|---|
true | |
false |
disablePlus
值 | 说明 |
---|---|
true | |
false |
disableMinus
值 | 说明 |
---|---|
true | |
false |
Events
事件名 | 说明 | 参数 |
---|---|---|
change | 值改变时触发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="步进器" :bold="true">
<ux-text text="支持整数、小数步进,可长按快速步进"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
<ux-row>
<ux-numberbox theme="primary"</ux-numberbox>
<ux-numberbox theme="warning" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="样式" :bold="true">
<ux-text text="支持配置输入框宽度、按钮圆角、+-按钮显示" :mb="15"></ux-text>
<ux-col>
<ux-numberbox :value="99" :width="80" input-color="#a90000" input-dark-color="#a90000" font-color="white" font-dark-color="white"></ux-numberbox>
<ux-numberbox :radius="true" :mt="10"></ux-numberbox>
<ux-numberbox :minus="false" :mt="10"></ux-numberbox>
<ux-numberbox :plus="false" :min="-10" :mt="10"></ux-numberbox>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="步进" :bold="true">
<ux-text text="支持整数、小数步进,可控制小数精度、最大值和最小值" :mb="15"></ux-text>
<ux-row>
<ux-numberbox :step="5" :min="-30" :max="30"></ux-numberbox>
<ux-numberbox :decimal="true" :step="0.1" :precision="2" :min="-10" :max="10" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="长按步进" :bold="true">
<ux-text text="开启长按手势可快速步进" :mb="15"></ux-text>
<ux-row>
<ux-numberbox :longpress="true"></ux-numberbox>
<ux-numberbox :longpress="true" :decimal="true" :step="0.1" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="禁用" :bold="true">
<ux-text text="支持分别单独禁用+-按钮、输入框" :mb="15"></ux-text>
<ux-col>
<ux-numberbox :disabled="true"></ux-numberbox>
<ux-numberbox :disable-minus="true" theme="primary" :mt="10"></ux-numberbox>
<ux-numberbox :disable-plus="true" theme="warning" :min="-10" :mt="10"></ux-numberbox>
</ux-col>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="步进器" :bold="true">
<ux-text text="支持整数、小数步进,可长按快速步进"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
<ux-row>
<ux-numberbox theme="primary"</ux-numberbox>
<ux-numberbox theme="warning" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="样式" :bold="true">
<ux-text text="支持配置输入框宽度、按钮圆角、+-按钮显示" :mb="15"></ux-text>
<ux-col>
<ux-numberbox :value="99" :width="80" input-color="#a90000" input-dark-color="#a90000" font-color="white" font-dark-color="white"></ux-numberbox>
<ux-numberbox :radius="true" :mt="10"></ux-numberbox>
<ux-numberbox :minus="false" :mt="10"></ux-numberbox>
<ux-numberbox :plus="false" :min="-10" :mt="10"></ux-numberbox>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="步进" :bold="true">
<ux-text text="支持整数、小数步进,可控制小数精度、最大值和最小值" :mb="15"></ux-text>
<ux-row>
<ux-numberbox :step="5" :min="-30" :max="30"></ux-numberbox>
<ux-numberbox :decimal="true" :step="0.1" :precision="2" :min="-10" :max="10" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="长按步进" :bold="true">
<ux-text text="开启长按手势可快速步进" :mb="15"></ux-text>
<ux-row>
<ux-numberbox :longpress="true"></ux-numberbox>
<ux-numberbox :longpress="true" :decimal="true" :step="0.1" :ml="30"></ux-numberbox>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="禁用" :bold="true">
<ux-text text="支持分别单独禁用+-按钮、输入框" :mb="15"></ux-text>
<ux-col>
<ux-numberbox :disabled="true"></ux-numberbox>
<ux-numberbox :disable-minus="true" theme="primary" :mt="10"></ux-numberbox>
<ux-numberbox :disable-plus="true" theme="warning" :min="-10" :mt="10"></ux-numberbox>
</ux-col>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
ts
<script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/numberbox.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/numberbox.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>