vue3中的elementPlus全局組件中文轉(zhuǎn)換方式
elementPlus 全局組件中文轉(zhuǎn)換
在項目中使用日期下拉框發(fā)現(xiàn)是英文的,需要全局改成中文樣式。
代碼實現(xiàn)
在 App.vue 的文件中修改即可。
代碼如下
<template> ? ? <el-config-provider :locale="locale"> ? ? ? <router-view></router-view> ? ? </el-config-provider> </template>
<script lang="ts" setup> import { ElConfigProvider } from 'element-plus' import zhCn from 'element-plus/lib/locale/lang/zh-cn'; const { locale } = reactive({ ? locale: zhCn, }); </script>
參考官方鏈接:https://element-plus.org/en-US/guide/i18n.html#configprovider
elementPlus 設(shè)置默認(rèn)語言為中文
Element UI的默認(rèn)語言是英文。那么如何才能將其改成中文呢?
ElementUI 提供了國際化的支持,這里給出其中的一個改成中文的方法。
找到main.js 文件, 做如下改動:
import {createApp} from 'vue' import ElementPlus from 'element-plus'; import locale from "element-plus/lib/locale/lang/zh-cn";//需要新加的代碼 import App from './App.vue' import "element-plus/lib/theme-chalk/index.css"; let app = createApp(App); app.use(ElementPlus, {locale});//需要改變的地方,加入locale app.mount('#app');
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- springboot?vue接口測試前后端樹節(jié)點編輯刪除功能
- vue3+ElementPlus封裝函數(shù)式彈窗組件詳解
- 詳解Vue3.0中ElementPlus<input輸入框自動獲取焦點>
- vue3+ElementPlus使用lang="ts"報Unexpected?token錯誤的解決辦法
- vue3應(yīng)用elementPlus table并滾動顯示問題
- Vue3?+?elementplus實現(xiàn)表單驗證+上傳圖片+?防止表單重復(fù)提交功能
- Vue3+ElementPlus 表單組件的封裝實例
- vue3+elementplus 樹節(jié)點過濾功能實現(xiàn)
相關(guān)文章
Vue scrollBehavior 滾動行為實現(xiàn)后退頁面顯示在上次瀏覽的位置
這篇文章主要介紹了Vue scrollBehavior 滾動行為實現(xiàn)后退頁面顯示在上次瀏覽的位置,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05vue3中實現(xiàn)使用element-plus調(diào)用message
這篇文章主要介紹了vue3中實現(xiàn)使用element-plus調(diào)用message,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-09-09