fix:键盘输入bug
This commit is contained in:
@@ -81,8 +81,22 @@ const jianshao = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const changeNums = (item, index) => {
|
const changeNums = (item, index) => {
|
||||||
if (item.text === '.') {
|
const inputChar = item.text
|
||||||
if (nums.value.indexOf('.') !== -1 || nums.value.length === 0) {
|
// 处理负号 '-'
|
||||||
|
if (inputChar === '-') {
|
||||||
|
// 只允许在输入为空时输入负号(即只能作为第一个字符)
|
||||||
|
if (nums.value === '') {
|
||||||
|
nums.value = '-'
|
||||||
|
}
|
||||||
|
return // 无论是否成功,都不继续处理
|
||||||
|
}
|
||||||
|
if (inputChar === '.') {
|
||||||
|
// 不能以 '.' 开头(除非已有负号)
|
||||||
|
if (nums.value === '' || nums.value === '-') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 已存在小数点则不允许再输入
|
||||||
|
if (nums.value.indexOf('.') !== -1) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +110,7 @@ const changeNums = (item, index) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nums.value += item.text
|
nums.value += inputChar
|
||||||
}
|
}
|
||||||
|
|
||||||
const getListItemStyle = index => {
|
const getListItemStyle = index => {
|
||||||
|
|||||||
Reference in New Issue
Block a user