Reputation: 51
I trying to use v-mask package in vue using npm. i run the npm install v-mask
as the documentation says, but where exactly I should put in code to initialization? i tried to put it in the main.js file:
import { createApp } from 'vue'
import App from './App.vue'
import VueMask from 'v-mask'
Vue.use(VueMask);
createApp(App).mount('#app')
but get an error 'Vue' is not defined. what am I doing wrong?
Upvotes: 1
Views: 641
Reputation: 138656
v-mask
is built for Vue 2, so you can't use it in Vue 3 (unless you use the migration build, but that's not really intended for third party plugins).
Consider using maska
, which is a masking library that supports Vue 3:
npm i -S maska
Example usage:
import { createApp } from 'vue'
import App from './App.vue'
import Maska from 'maska'
createApp(App).use(Maska).mount('#app')
Upvotes: 1
Reputation: 1
try to save the app in a variable and execute use
for app
import { createApp } from 'vue'
import App from './App.vue'
import VueMask from 'v-mask'
const app = createApp(App)
app.use(VueMask)
app.mount('#app')
Upvotes: 0