vue-the-mask
vue-the-mask copied to clipboard
:mask not able to interpret an array when used as directive
Steps to simulate:
<input type="tel" v-else :mask="MyDataMask"/>
Being MyDataMask
a data field.
data() {
return {
MyDataMask: ['##, '###']
}
}
The mask simply doesn't work.
But if I do:
<input type="tel" v-else :mask="['##', '###']"/>
It works.
Also if I replace :mask
with v-mask
using the variable MyDataMask
it works, but I got the following error:
You may have an infinite update loop in a component render function.
same probelm, how to fix it?
@Naskalin, this repository seems to be unmaintained. Create a fork from #64 PR (or wait for the maintainer to merge it) or use other vuejs mask libraries like https://github.com/probil/v-mask
Any news on this subject? I tried copying the changes from #64 to my local files, but it didn't fix the issue for me.
My solution was use: v-mask="['###.###.###-##', '##.###.###/####-##'] and not use :mask="['###.###.###-##', '##.###.###/####-##'] this works to me.
This solution works for me:
<input type="text" class="form-control" v-mask="[...masks]" v-model="phone">
Value of "masks" variable:
["+55 (##) ####-####", "+55 (##) #####-####"]
I have a parent component that renders the input within a child component. Having that same issue where the pattern array is causing an infinite loop, when switching the
v-mask:mask="isInterestRate ? pattern2 : pattern"
to
v-mask="isInterestRate ? ['##.###','#.###'] : pattern",
the infinite loop goes away for array pattern. Thank you guys! been stuck on this for almost 2 weeks and i finally found this thread! woo!