vue3中Element Plus全局组件配置中文的两种方案

Element+是一款用于制作页面样式,设计页面结构的框架。相比于其他的几个框架,这个框架设计的更为人性化,对企业级框架VUE的集成也很高。

Element Plus 组件 默认 使用英语,如果你希望使用其他语言,你可以参考下面的两种方案。

1.在 App.vue 的文件中修改
<template>
    <el-config-provider :locale="locale">
      <router-view></router-view>
    </el-config-provider>
</template>

<script setup>
// // 引入配置组件
import { ElConfigProvider } from 'element-plus'
// 引入中文包
import zhCn from 'element-plus/lib/locale/lang/zh-cn';
 
const { locale } = reactive({
  locale: zhCn,
});
</script>
2.在main.js的文件中修改
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

app.use(ElementPlus, {
  locale: zhCn,
})
国际化

Element Plus 还提供了一个 Vue 组件 ConfigProvider 用于全局配置国际化的设置。

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

<script>
  import { defineComponent } from 'vue'
  import { ElConfigProvider } from 'element-plus'

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

  export default defineComponent({
    components: {
      ElConfigProvider,
    },
    setup() {
      return {
        locale: zhCn,
      }
    },
  })
</script>

相关推荐

  1. vue3Element Plus全局组件配置方案

    2023-12-13 16:58:04       40 阅读
  2. Vue3ElementPlusTable选中数据获取与清空方法

    2023-12-13 16:58:04       31 阅读
  3. vue组件之间通信方式有多少

    2023-12-13 16:58:04       34 阅读
  4. vue3覆盖组件样式方法

    2023-12-13 16:58:04       16 阅读
  5. VueElementPlus按需导入

    2023-12-13 16:58:04       16 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-13 16:58:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-13 16:58:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-13 16:58:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-13 16:58:04       20 阅读

热门阅读

  1. Temporal 服务限制说明

    2023-12-13 16:58:04       44 阅读
  2. Spring框架中的8种设计模式

    2023-12-13 16:58:04       37 阅读
  3. 每日一练 | 华为认证真题练习Day29

    2023-12-13 16:58:04       41 阅读
  4. 选择排序

    2023-12-13 16:58:04       40 阅读
  5. 【Android】通知(未完待续)

    2023-12-13 16:58:04       43 阅读
  6. PHP中什么是命名空间(Namespace)?

    2023-12-13 16:58:04       43 阅读
  7. 多个变量存储同一个地址

    2023-12-13 16:58:04       39 阅读
  8. 只需六个简单步骤即可开发自定义应用程序

    2023-12-13 16:58:04       28 阅读