根据提供的代码,看起来翻页组件的翻译无效的问题可能是由于在total-text属性中使用了$t函数的原因。$t函数是用于在组件中动态翻译文本的方法,但是它不能直接在模板中使用。

要解决这个问题,您可以在组件的data选项中定义一个属性,并在模板中使用该属性来显示翻译后的文本。以下是一个示例:

<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :hide-on-single-page="isShowPage"
    :current-page="currentPage"
    :page-sizes="[10, 20, 30, 40]"
    :page-size="100"
    layout="total, sizes, prev, pager, next, jumper"
    :total="tableData.length"
    :total-text="paginationText"
  ></el-pagination>
</template>

<script>
export default {
  data() {
    return {
      paginationText: '',
    };
  },
  mounted() {
    this.paginationText = this.$t('pagination.all.5sbpztum4c20', { total: this.tableData.length });
  },
};
</script>

在上面的代码中,我们在组件的data选项中定义了一个名为paginationText的属性,并在组件挂载后使用mounted钩子函数来设置该属性的值。我们使用$t函数来翻译文本,并使用{ total: this.tableData.length }作为参数传递给$t函数,以便在翻译文本中使用{total}占位符来表示总数。

然后,我们将paginationText属性绑定到total-text属性,以便在模板中显示翻译后的文本。

这样,您应该能够解决翻页组件翻译无效的问题

i18n翻译翻页组件无效的问题 zh pagination all 5sbpztum4c20 共 total 条数据 en pagination all 5sbpztum4c20 Total total items el-pagination size-change=hand

原文地址: https://www.cveoy.top/t/topic/iVTj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录