javascript - 使用 Imask 的可选十进制长度
问题描述
我正在使用 IMask 在我的应用程序中屏蔽百分比输入。默认小数长度应为 2,但用户应该能够编写更具体的小数,直到点后 5 个字符。在大多数情况下,我当前的代码运行良好:
st PERCENTAGE_MASK = {
mask: 'num[000]%',
lazy: false,
blocks: {
num: {
mask: Number,
scale: 2, // digits after point, 0 for integers
signed: false, // disallow negative
padFractionalZeros: true, // if true, then pads zeros at end to the length of scale
normalizeZeros: true, // appends or removes zeros at ends
min: 0,
max: 100,
radix: '.', // fractional delimiter
mapToRadix: [',', '.'], // symbols to process as radix
},
},
但是,当用户开始写入 2 个零时,点将被忽略。有人对这种情况有很好的解决方案吗?提前致谢
解决方案
推荐阅读
- ios - 如何在 SwiftUI 中单击按钮时添加 UI 组件?
- javascript - 如何在javascript中找到两次之间的差异?
- sql-server - 为什么 SQL Server 在数据后插入全范围的空格
- python - 事件的 Asyncio NotImplementedError
- python - 在Flask中使用render_template,如何将字符串拆分为多行?
- javascript - JSON写入文件不会更新,只是替换
- apache - 使用 OR 的 htaccess 中的禁止规则不起作用
- python - 图像画布未正确更新
- php - 使用 PHP 和 MySQL 查询为一系列数据创建 JSON
- ruby-on-rails - Net::SMTPAuthenticationError: 530-5.7.0 Authentication Required Rails Mailer 在配置中使用环境变量