0

I am a novice and have been using vite recently. I have tested it and Google it, but I am still unable to solve the problem

In vite app, when i import element-plus type,like ElInput...

Error: Module 'element plus' does not have an exported member' FormInstance '. Do you want to use 'import FormInstance from' element plus' instead

but I can use in vue init app

use

npm init vue

create my project,install element-plus

npm i element-plus

In app.vue I can use the below code

import type { FormInstance } from 'element-plus';
import type { ElInput } from 'element-plus'

but use

npm create vite

create my project,the same install element-plus

npm i element-plus

In app.vue If I use the same code

import type { FormInstance } from 'element-plus';
import type { ElInput } from 'element-plus'

2 Answers2

0

you must configure elementPlus in your main.js file.

import './assets/main.css'

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'

createApp(App)
.use(ElementPlus)
.mount('#app')

then in your views you use the components as in the documentation

<el-button type="primary">Primary</el-button>
lalan21j
  • 167
  • 2
  • 5
0

in your tsconfig.json add this:

"include": ["./src/**/*"]
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 21 '23 at 11:16