Anyone with and Idea how to fix app.use is not a function after installing Element-plus using npm in vue3

Viewed 406

So after installing Vue 3.0 based component library (Element-Plus) in my project using npm install element-plus --save, I get this error that says app.use is not a function. I have also imported Element fully like so:

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import "./assets/Css/Style.css"
app.use(ElementPlus)
createApp(App).use(router).mount('#app').

But I get the under-listed error. Uncaught TypeError: app.use is not a function

1 Answers

You need to initialize Vue with createApp(), before you can use .use. Like this:

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import "./assets/Css/Style.css"
const app = createApp(App)
app.use(ElementPlus)
app.use(router)
app.mount('#app').
Related