element plus的日歷改成中文的


場景:使用日歷發現只有英文,想改成中文的日歷

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM