ElementPlus引入汉化文件报错踩坑

发布时间 2023-07-20 17:49:07作者: 初生土豆

按照官网的方法引入zhCn

import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

编辑器报错:Could not find a declaration file for module 'element-plus/dist/locale/zh-cn.mjs'. 'c:/Users/LL/Desktop/cloudUI2.0/node_modules/element-plus/dist/locale/zh-cn.mjs' implicitly has an 'any' type. If the 'element-plus' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'element-plus/dist/locale/zh-cn.mjs';`

解决方法在项目根目录 env.d.ts中添加下面这行代码

declare module 'element-plus/dist/locale/zh-cn.mjs';