Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

使用vue3 和 element-plus 练习时设置语言时报错

最近使用vite构建一个vue3和element-plus的项目练手,但是在使用element-plus设置语言时报错,根据官网的提示,我引用了如下代码:

import lang from 'element-plus/lib/locale/lang/zh-cn'
import locale from 'element-plus/lib/locale'

// 设置语言
locale.use(lang)

image.png
随后在浏览器中报错:
image.png
然后在vsCode中的终端也有相应的错误信息:
image.png


哪位大佬帮忙看看这是什么原因,有什么好的解决办法?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

vite.config.js
加上
optimizeDeps: {

include: ["element-plus/lib/locale/lang/zh-cn"],

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...