0

My question is very similar to this one for angular: In angular-imask how do I get the IMask class? I'm especially interested about the Vue Composition API https://github.com/uNmAnNeR/imaskjs/tree/master/packages/vue-imask#mask-composable-vue-3 to be able to call mask.updateValue() in order to make it work with VeeValidate (ex: https://vee-validate.logaretm.com/v4/examples/value-formatting).

Here is the message I get from the console:

Element value was changed outside of mask. Syncronize mask using mask.updateValue() to work properly.

I've tried to retrieve the IMask class like that const { mask } = useIMask(formatterMask) but it is not the IMask class unfortunatly.

Any idea how to proceed? Thank you.

lbineau
  • 73
  • 2
  • 9

1 Answers1

1

The IMask instance is indeed stored in mask returned from useIMask(). Since mask is a ref, you need to unwrap it via its .value property:

const { mask } = useIMask(formatterMask)

console.log(mask.value) // => IMask instance
tony19
  • 125,647
  • 18
  • 229
  • 307
  • Thank you, I can now access it. The point now is I get an error by calling `mask.value.update()` saying the object read-only and cannot be modified (https://github.com/uNmAnNeR/imaskjs/blob/d34f6f3/packages/vue-imask/src/composable.js#L93) Any idea how to get around that issue without forking the library? – lbineau May 23 '22 at 15:59