Vue3项目给ElementPlus设置中文的两个方案

介绍

Vue3项目将ElementPlus切换为中文

1、在App.vue的文件中修改

复制代码
<template>
	<el-config-provider :locale="zhCn">
		<router-view></router-view>
	</el-config-provider>
</template>

<script lang="ts" setup>
	import { ElConfigProvider } from 'element-plus';
  	import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
</script>

2、在main.ts的文件中修改

复制代码
// main.ts
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
//引入中文文件
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const app = createApp(App)
//设置中文
app.use(ElementPlus,{
    locale: zhCn,
})
app.mount('#app')
相关推荐
lbaihao1 天前
LLVM Cpu0 调用规则解析
开发语言·前端·python·llvm
hexu_blog1 天前
前端vue 后端springboot如何实现图片去水印
前端·javascript·vue.js
whuhewei1 天前
React搜索框组件
前端·javascript·react.js
姓王者1 天前
Cloudflare Pages自定义依赖安装实践 | 姓王者的博客
前端
spmcor1 天前
前端 RBAC 权限控制实战:从零实现动态路由与细粒度按钮权限
vue.js
stringwu1 天前
Flutter 开发的 AI 三件套:壮汉、法师、实习生
前端
spmcor1 天前
Vue 2 vs Vue 3:核心差异深度剖析与迁移指南
vue.js
代码搬运媛1 天前
BFF 架构浅析:再也不用求后端改接口了
前端
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_50:(深入理解 DOM 中的 Text 节点)
前端·javascript·microsoft·ui·html·媒体
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_51:(深入理解 XPathEvaluator 接口)
前端·javascript·ui·html·音视频