maska
maska copied to clipboard
Vue 3: "Failed to resolve directive: maska"
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.
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.
This comment helped me. Thanks a lot!
If you want to use it as directive try this;
import { maska } from "maska";
const app = createApp(App);
app.directive('maska', maska )
import { maska as vMaska } from 'maska'
works for Custom Element
New version (v2.0) has more consistent exports.
I'm facing this error on Nuxt 3. Followed the docs to create the plugin.