pagination prev 上一页 next 下一页 page 第 goto 跳转到 p 页 total 共 items 条 el-pagination size-change=handleSizeChange current-change=handleCurrentChange hide-on-single-page
在你的代码中,你需要在导入语言文件之后将i18n实例挂载到Vue实例中。你的代码应该像这样修改:
// main.js
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import zh from './lang/zh.js' // 导入语言文件
import en from './lang/en.js'
Vue.use(VueI18n)
const messages = {
zh,
en
}
const i18n = new VueI18n({
locale: 'zh', // 设置默认语言为中文
messages
})
new Vue({
i18n,
//...
}).$mount('#app')
// 然后在el-pagination组件中使用$t方法来翻译文本
<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="$t('pagination.total')"
>
</el-pagination>
这样应该可以解决你的问题。请确保你的语言文件zh.js和en.js中正确定义了pagination对象,以及在el-pagination组件中传入了正确的翻译键
原文地址: http://www.cveoy.top/t/topic/iVUl 著作权归作者所有。请勿转载和采集!