[Nuxt3系列教程] Nuxt3.7.3 ElementPlus分页组件修改默认英文设置

发布日期 2023-10-03 15:08:45 已于 2023-11-22 23:55:53 修改

ElementPlus UI框架默认的分页组件显示的是英文模式,官方文档也有介绍可以更改为中文:

Config Provider 全局配置

通过 Config Provider 来配置多语言,让你的应用可以随时切换语言。

<template>
  <div>
    <el-button mb-2 @click="toggle">Switch Language</el-button>
    <br />

    <el-config-provider :locale="locale">
      <el-table mb-1 :data="[]" />
      <el-pagination :total="100" />
    </el-config-provider>
  </div>
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'

const language = ref('zh-cn')
const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en))

const toggle = () => {
  language.value = language.value === 'zh-cn' ? 'en' : 'zh-cn'
}
</script>
年末感恩回馈