vue-the-mask icon indicating copy to clipboard operation
vue-the-mask copied to clipboard

:mask not able to interpret an array when used as directive

Open raphaklaus opened this issue 7 years ago • 6 comments

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.

raphaklaus avatar Feb 20 '18 15:02 raphaklaus

same probelm, how to fix it?

Naskalin avatar Sep 04 '18 20:09 Naskalin

@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

raphaklaus avatar Sep 04 '18 20:09 raphaklaus

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.

atmonello avatar Dec 05 '18 19:12 atmonello

My solution was use: v-mask="['###.###.###-##', '##.###.###/####-##'] and not use :mask="['###.###.###-##', '##.###.###/####-##'] this works to me.

william-cwb avatar May 18 '20 22:05 william-cwb

This solution works for me:

<input type="text" class="form-control" v-mask="[...masks]" v-model="phone">

Value of "masks" variable:

["+55 (##) ####-####", "+55 (##) #####-####"]

jeff-silva avatar Jan 22 '21 03:01 jeff-silva

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!

CLMokbel avatar May 18 '23 14:05 CLMokbel