提交 7f93b736 编写于 作者: D DCloud_LXH

feat: input 添加 tel 属性、添加 text-content-type 属性

上级 adf62653
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
:enterkeyhint="confirmType" :enterkeyhint="confirmType"
:pattern="type === 'number' ? '[0-9]*' : null" :pattern="type === 'number' ? '[0-9]*' : null"
class="uni-input-input" class="uni-input-input"
autocomplete="off" :autocomplete="autocomplete"
@change.stop @change.stop
@focus="_onFocus" @focus="_onFocus"
@blur="_onBlur" @blur="_onBlur"
...@@ -54,8 +54,10 @@ ...@@ -54,8 +54,10 @@
import { import {
field field
} from 'uni-mixins' } from 'uni-mixins'
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password'] import { kebabCase } from 'uni-shared'
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password', 'tel']
const NUMBER_TYPES = ['number', 'digit'] const NUMBER_TYPES = ['number', 'digit']
const AUTOCOMPLETES = ['off', 'one-time-code']
export default { export default {
name: 'Input', name: 'Input',
mixins: [field], mixins: [field],
...@@ -95,6 +97,10 @@ export default { ...@@ -95,6 +97,10 @@ export default {
confirmType: { confirmType: {
type: String, type: String,
default: 'done' default: 'done'
},
textContentType: {
type: String,
default: ''
} }
}, },
data () { data () {
...@@ -126,6 +132,16 @@ export default { ...@@ -126,6 +132,16 @@ export default {
step () { step () {
// 处理部分设备中无法输入小数点的问题 // 处理部分设备中无法输入小数点的问题
return ~NUMBER_TYPES.indexOf(this.type) ? '0.000000000000000001' : '' return ~NUMBER_TYPES.indexOf(this.type) ? '0.000000000000000001' : ''
},
autocomplete () {
const camelizeIndex = AUTOCOMPLETES.indexOf(this.textContentType)
const kebabCaseIndex = AUTOCOMPLETES.indexOf(kebabCase(this.textContentType))
const index = camelizeIndex !== -1
? camelizeIndex
: kebabCaseIndex !== -1
? kebabCaseIndex
: 0
return AUTOCOMPLETES[index]
} }
}, },
watch: { watch: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册