fix: 输入校验统一字符串防御(数字输入不再引发 trim 类型崩溃)
This commit is contained in:
@@ -57,8 +57,9 @@ function computedCategory() {
|
||||
}
|
||||
|
||||
function save() {
|
||||
const v = Number(fAmount.value)
|
||||
if (!fAmount.value.trim() || !isFinite(v) || v <= 0) {
|
||||
const amountText = String(fAmount.value ?? '').trim()
|
||||
const v = Number(amountText)
|
||||
if (!amountText || !isFinite(v) || v <= 0) {
|
||||
fError.value = '请填写大于 0 的金额'
|
||||
return
|
||||
}
|
||||
@@ -72,7 +73,7 @@ function save() {
|
||||
category: computedCategory(),
|
||||
amount: Math.round(v * 100),
|
||||
date: fDate.value,
|
||||
note: fNote.value.trim(),
|
||||
note: String(fNote.value ?? '').trim(),
|
||||
reimbursable,
|
||||
reimbursed: reimbursable && fReimbursed.value ? 1 : 0
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user