这几天用vue-cli5+typescript写vue,发现使用elment-plus报错了。

先跟着vscode尝试一波

  Try `npm i --save-dev @types/element-plus` if it exists or add a new declaration (.d.ts) file containing `declare module 'element-plus';

结果是

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.com/@types%2felement-plus - Not found
npm ERR! 404
npm ERR! 404 '@types/element-plus@*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

没有这个模块,那么我们只能自己去声明了。
这里记录一个方法,我在


添加提示

shims-vue.d.ts
新建

declare module 'element-plus'


于是就能完美解决了

版权属于:染念
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
更新于: 2021年03月15日 19:28
4


182 文章数
695 评论量
4 分类数
185 页面数
已在风雨中度过 7年166天19小时27分
目录
来自 《Could not find a declaration file for module 'element-plus'.》
© 2024 染念的笔记
浙ICP备19020194号-1
暗黑模式
暗黑模式
评论
返回顶部
© 2024 染念的笔记
浙ICP备19020194号-1
暗黑模式
暗黑模式
评论
返回顶部