在普通的html中,使用js引入的方式来汉化element-plus

1,074 阅读1分钟

此方法只适合在普通的html中element-plus的架构中使用,使用element前提还需要引入vue插件。。因为layui的退场,公司就决定使用element作为项目前端框架,使用中碰到了非常多的问题,我之前都是使用layui的,直接js引用那种方式,现在element使用起来很别扭,但是无奈,只有适应。

1下载element-plus中文插件

unpkg.com/browse/elem…

2.复制js内容,保存到zh-cn.js中

  1. 把js中export default修改为let zhCn = 在这里插入图片描述 在这里插入图片描述
  2. 引用vue3.0.js+element-plus.js之后再引用zh-cn.js
<script type="text/javascript" src="/config/zh-cn.js"></script>

3.在js中调用zh-cn插件

const app = Vue.createApp({
    data: function () {
        return {

        }
    },
});
app.use(ElementPlus, {
    locale: zhCn,
});
app.mount('#testManageId')

4效果展示

  1. 汉化之前

在这里插入图片描述 2. 汉化之后 在这里插入图片描述