报错
index.91fbdfd0.js:4 Uncaught Error: [DecimalError] Invalid argument: .0
at Te (decimal.b86a5a0e.js:7:24193)
at new s (decimal.b86a5a0e.js:7:28912)
at ve (weigh-code-index-new-2.ada73f1e.js:1:7136)
at onClick (weigh-code-index-new-2.ada73f1e.js:1:23302)
at callWithErrorHandling (index.91fbdfd0.js:4:1653)
at callWithAsyncErrorHandling (index.91fbdfd0.js:4:1789)
at HTMLDivElement.xe (index.91fbdfd0.js:14:18458)
很神奇,工控端手点屏幕报错,电脑上鼠标点击,没问题。
这是一个常见的 decimal.js 库错误。问题在于你传入了一个格式为 .0(以小数点开头但缺少前导零)的字符串,而 decimal.js 无法解析这种格式。
问题原因
// ❌ 错误:缺少前导零
new Decimal('.0') // 抛出 DecimalError: Invalid argument: .0
new Decimal('.123') // 同样会报错
// ✅ 正确:需要前导零
new Decimal('0.0') // 正常工作
new Decimal('0.123') // 正常工作
源代码
调用 new Decimal(plateCount)方法时,里面的值可能为".0"

新增方法normalizeDecimalValue 规范化数值,确保 Decimal 能正确处理(避免 ".0" 等无效格式)

