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

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

上级 adf62653
<template>
<uni-input v-on="$listeners">
<div
ref="wrapper"
class="uni-input-wrapper"
<div
ref="wrapper"
class="uni-input-wrapper"
>
<div
v-show="!(composing || valueSync.length || cachedValue === '-')"
......@@ -25,7 +25,7 @@
:enterkeyhint="confirmType"
:pattern="type === 'number' ? '[0-9]*' : null"
class="uni-input-input"
autocomplete="off"
:autocomplete="autocomplete"
@change.stop
@focus="_onFocus"
@blur="_onBlur"
......@@ -54,8 +54,10 @@
import {
field
} 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 AUTOCOMPLETES = ['off', 'one-time-code']
export default {
name: 'Input',
mixins: [field],
......@@ -95,6 +97,10 @@ export default {
confirmType: {
type: String,
default: 'done'
},
textContentType: {
type: String,
default: ''
}
},
data () {
......@@ -126,6 +132,16 @@ export default {
step () {
// 处理部分设备中无法输入小数点的问题
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: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册