場景:使用日歷發現只有英文,想改成中文的日歷
1.參照官網 https://element-plus.gitee.io/#/zh-CN/component/i18n 進行全局化配置失敗
2.使用 【ConfigProvider】進行配置,后面發現僅僅用來當前頁面對單個控件有效,如果放到App.vue里頭(這邊想是把App.vue當做母版頁來使用的),會導致頁面無限循環生成
3.使用
<!--日歷圖表--> <el-row :gutter="20" class="home_head" style="margin-top: 20px;"> <el-col> <el-card> <el-config-provider :locale="locale"> <el-calendar v-model="nowDateValue"> </el-calendar> </el-config-provider> </el-card> </el-col> </el-row> <script> import { ElConfigProvider } from 'element-plus' import zhCn from 'element-plus/lib/locale/lang/zh-cn' export default { components: { [ElConfigProvider.name]: ElConfigProvider }, setup () { return { locale: zhCn } }, data () { return { nowDateValue: new Date() } } } </script>
感謝:https://blog.csdn.net/qq_42786011/article/details/119735815
參考:https://element-plus.gitee.io/#/zh-CN/component/i18n