maska icon indicating copy to clipboard operation
maska copied to clipboard

Vue 3: "Failed to resolve directive: maska"

Open vsirghii opened this issue 1 year ago • 4 comments

Hello, I have installed "maska": "^1.5.0" and I have the following in my vue 3 main.js:

import Maska from 'maska';
const app = createApp(App);
app.directive('maska', Maska.maska)

and then in a component: <CFormInput id="companyein" v-model="model.employerNumber" placeholder="##-#######" v-maska="'##-#######'" />

With this setup I'm getting error "Failed to resolve directive: maska" and the component won't open.

vsirghii avatar Aug 13 '22 06:08 vsirghii

Seems like app.directive() doesn't work. I changed it to app.use(Maska) and now everything works as expected. It's just a bit confusing that I use Maska as a directive (v-maska="...") but setting it as a plugin (app.use(Maska) instead of app.directive('maska', Maska.maska)) Anyways, thanks for your component, it's really helpful.

vsirghii avatar Aug 13 '22 07:08 vsirghii

This comment helped me. Thanks a lot!

nagisaando avatar Aug 17 '22 21:08 nagisaando

If you want to use it as directive try this;

import { maska } from "maska";
const app = createApp(App);
app.directive('maska',  maska )

guifarro avatar Sep 25 '22 04:09 guifarro

import { maska as vMaska } from 'maska'

works for Custom Element

dimatall avatar Sep 27 '22 21:09 dimatall

New version (v2.0) has more consistent exports.

beholdr avatar Dec 04 '22 15:12 beholdr

I'm facing this error on Nuxt 3. Followed the docs to create the plugin.

ebisu48 avatar Apr 29 '24 21:04 ebisu48