作者:Lanboream | 来源:互联网 | 2023-09-16 11:55
I found a very nice inputmask for a decimal number:
1 2 3
| $(document).ready(function(){
$(".decimal").inputmask({ 'alias': 'decimal', 'radixPoint': '.', 'groupSeparator': ',', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'placeholder': '0.00', rightAlign : true});
}); |
This works great in JSFiddle. However when I try to use it with Vue.js, I'm getting an error. Here is the code:
1 2 3 4 5 6 7
| function(Vue, options) {
Vue.directive('mask', {
bind: function(el, binding) {
InputMask({ 'alias': 'decimal', 'radixPoint': '.', 'groupSeparator': ',', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'placeholder': '0.00', rightAlign : true}).mask(el);
}
});
} |
And this comes out if I try to type anything in the input field:
1 2 3 4 5
| Uncaught TypeError: Cannot create property 'rewritePosition' on boolean 'true'
at processCommandObject (inputmask:1245)
at isValid (inputmask:1269)
at HTMLInputElement.keypressEvent (inputmask:1585)
at HTMLInputElement.ev (inputmask:1530) |
The problem is caused by the presence of 'alias' property, without it the error is not there (but it obviously also doesn't work).
I can't find why alias should not work in Vue.js
Version of plugin is 5.0.0-beta.161
该提问来源于开源项目:RobinHerbots/Inputmask
Thank you for the correction!