“autoNumeric”插件会在字段聚焦甚至悬停时立即用零填充输入字段。我想让最终用户将某些字段留空。空白与零不同。有没有解决方案?
答案 0 :(得分:2)
查看emptyInputBehavior
文件中AutoNumericOptions.js
选项的文档:
/* Defines what should be displayed in the element if the raw value is an empty string ('').
* - 'focus' : The currency sign is displayed when the input receives focus (default)
* - 'press' : The currency sign is displayed whenever a key is being pressed
* - 'always' : The currency sign is always displayed
* - 'zero' : A zero is displayed ('rounded' with or without a currency sign) if the input has no value on focus out
* - 'null' : When the element is empty, the `rawValue` and the element value/text is set to `null`. This also allows to set the value to `null` using `anElement.set(null)`.
*/
emptyInputBehavior: {
null : 'null',
focus : 'focus',
press : 'press',
always: 'always',
zero : 'zero',
},
您想要的是将emptyInputBehavior
设置为'focus'
(这是默认设置),并且您不会在输入中添加任何“零”。
这与v4
中的next
版本有关。