检查package.json
中的devDependencies
是否安装@vue/runtime-core
依赖,没有的话,安装后重启VS Code
一、安装依赖
$ yarn add @vue/runtime-core -D
$ yarn add unplugin-vue-components -D
二、配置
vite.config.ts
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
{
plugins: [
Components({
extensions: ['vue'],
include: [/\.vue$/, /\.vue\?vue/],
resolvers: ElementPlusResolver()
})
]
}
tsconfig.json
{
"include": [
"./components.d.ts",
]
}