在 vue-imask 中如何获取 IMask class?

In vue-imask how do I get the IMask class?

我的问题与 angular 的这个问题非常相似: 我对 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).

这是我从控制台收到的消息:

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

我试过像那样检索 IMask class,但不幸的是它不是 IMask class。

知道如何进行吗? 谢谢。

IMask实例确实是stored in mask returned from useIMask(). Since mask is a ref,你需要通过它的.value解包属性:

const { mask } = useIMask(formatterMask)

console.log(mask.value) // => IMask instance