Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
b5bf7e4a
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b5bf7e4a
编写于
7月 05, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 废弃 input 组件 verifyNumber 参数
上级
42e78dd3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
29 deletion
+18
-29
src/core/view/components/input/index.vue
src/core/view/components/input/index.vue
+18
-29
未找到文件。
src/core/view/components/input/index.vue
浏览文件 @
b5bf7e4a
...
...
@@ -5,7 +5,7 @@
class=
"uni-input-wrapper"
>
<div
v-show=
"!(composing || valueSync.length ||
!valid
)"
v-show=
"!(composing || valueSync.length ||
cachedValue === '-'
)"
ref=
"placeholder"
:style=
"placeholderStyle"
:class=
"placeholderClass"
...
...
@@ -94,15 +94,10 @@ export default {
confirmType
:
{
type
:
String
,
default
:
'
done
'
},
verifyNumber
:
{
type
:
Boolean
,
default
:
false
}
},
data
()
{
return
{
valid
:
true
,
wrapperHeight
:
0
,
cachedValue
:
''
}
...
...
@@ -184,8 +179,8 @@ export default {
return
}
// type="number" 不支持 maxlength 属性,因此需要主动限制长度。
if
(
this
.
inputType
===
'
number
'
)
{
// type="number" 不支持 maxlength 属性,因此需要主动限制长度。
const
maxlength
=
parseInt
(
this
.
maxlength
,
10
)
if
(
maxlength
>
0
&&
$event
.
target
.
value
.
length
>
maxlength
)
{
// 输入前字符长度超出范围,则不触发input,且将值还原
...
...
@@ -198,37 +193,31 @@ export default {
this
.
valueSync
=
$event
.
target
.
value
}
}
}
if
(
~
NUMBER_TYPES
.
indexOf
(
this
.
type
))
{
// 在输入 - 负号 的情况下,event.target.value没有值,但是会触发校验 false
this
.
valid
=
this
.
$refs
.
input
.
validity
&&
this
.
$refs
.
input
.
validity
.
valid
if
(
!
this
.
verifyNumber
)
{
this
.
cachedValue
=
this
.
valueSync
}
else
{
// 处理部分输入法可以输入其它字符的情况,此处理无法先输入 -(负号),只能输入数字再移动光标输入负号
if
(
this
.
$refs
.
input
.
validity
&&
!
this
.
valid
)
{
$event
.
target
.
value
=
this
.
cachedValue
this
.
valueSync
=
$event
.
target
.
value
// 输入非法字符不触发 input 事件
// 数字类型输入错误时无法获取具体的值,自定义校验和纠正。
this
.
__clearCachedValue
&&
$event
.
target
.
removeEventListener
(
'
blur
'
,
this
.
__clearCachedValue
)
if
(
$event
.
target
.
validity
&&
!
$event
.
target
.
validity
.
valid
)
{
if
((
!
this
.
cachedValue
&&
$event
.
data
===
'
-
'
)
||
(
this
.
cachedValue
[
0
]
===
'
-
'
&&
$event
.
inputType
===
'
deleteContentBackward
'
))
{
this
.
cachedValue
=
'
-
'
const
clearCachedValue
=
this
.
__clearCachedValue
=
()
=>
{
this
.
cachedValue
=
''
}
$event
.
target
.
addEventListener
(
'
blur
'
,
clearCachedValue
)
return
}
else
{
this
.
cachedValue
=
this
.
valueSync
}
this
.
cachedValue
=
this
.
valueSync
=
$event
.
target
.
value
=
this
.
cachedValue
===
'
-
'
?
''
:
this
.
cachedValue
// 输入非法字符不触发 input 事件
return
}
else
{
this
.
cachedValue
=
this
.
valueSync
}
}
if
(
outOfMaxlength
)
return
this
.
$triggerInput
(
$event
,
Object
.
assign
(
{
this
.
$triggerInput
(
$event
,
{
value
:
this
.
valueSync
},
(()
=>
{
if
(
!
this
.
verifyNumber
)
{
return
{
valid
:
this
.
valid
}
}
})()),
force
)
},
force
)
},
_onComposition
(
$event
)
{
if
(
$event
.
type
===
'
compositionstart
'
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录