Element-Plus 配置中文国际化

方法一

  • 在 main.js 文件中,如下配置
  • 注意:项目中 Element-Plus 无论用不用 CDN 都需要安装。安装好 Element-Plus 下面的配置才会在开发环境生效。
  • 如果使用CDN打包,项目中需要单独引入element-plus的中文js文件。
  • 建议:建议使用方法一
import { createApp } from "vue";
import App from "./App.vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import locale from "element-plus/lib/locale/lang/zh-cn";

const app = createApp(App);
app.use(ElementPlus, { locale });
app.mount("#app");

方法二

  • 如果使用CDN 在 index.html 文件引入 CDN js文件
<script src="https://cdn.staticfile.org/element-plus/2.1.11/locale/zh-cn.min.js"></script>
  • 在 app.vue 文件
<script setup>
imp...

const locale = ElementPlusLocaleZhCn;
</script>

<template>
  <el-config-provider :locale="locale" />
  <router-view />
</template>

<style>
</style>
posted @ 2022-06-27 10:18  代码召唤师  阅读(1568)  评论(0编辑  收藏  举报