这几天用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'

于是就能完美解决了