Search code examples
vue.jsvuejs3vue-composition-apielement-ui

how to add Element UI to Vue 3


I am trying to add Element UI into my Vue3 Project:

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

App.use(ElementUI)
createApp(App).use(store).use(router).mount('#app')

So I am following this documentation https://element.eleme.io/#/en-US/component/quickstart but it gives me this error: types.js?a742:39 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')

I dont know what I am doing wrong in this regard.


Solution

  • You should use element-plus which is compatible with vue 3:

    Installation :

      npm install element-plus --save
    

    Usage :

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