Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: vxe-table的column title 国际化切换时不生效 #5213

Closed
5 tasks done
li-yi-hong opened this issue Dec 23, 2024 · 2 comments
Closed
5 tasks done

Bug: vxe-table的column title 国际化切换时不生效 #5213

li-yi-hong opened this issue Dec 23, 2024 · 2 comments

Comments

@li-yi-hong
Copy link

Version

Vben Admin V5

Describe the bug?

在切换国际化语言时,vxe-table的column title 未跟随变化,只有在强制刷新时才会变化。

Reproduction

  1. 在定义columns时,使用 $t 进行翻译
    import { $t } from '@vben/locales';
    export const columns: VxeGridProps['columns'] = [
    { type: 'checkbox', width: 60 },
    {
    field: 'username',
    title: $t('ui.column.username'),
    minWidth: 80,
    },
    {
    field: 'nickName',
    title: $t('ui.column.nickName'),
    minWidth: 130,
    },
    ...
    ]

QQ20241223-114144

System Info

no output

Relevant log output

No response

Validations

@mynetfan
Copy link
Collaborator

测试没有重现。请说明可以稳定重现的具体操作步骤

@li-yi-hong
Copy link
Author

我重新试了下,当 columns 定义在外部文件,例如 vxe-table 在index.vue, 而columns在data.ts中,会出现这个问题。查了下,估计是 $t 方法的调用时机的原因。我用 computed 包裹 columns 后问题得已解决,如下所示:

export const useColumns = () =>
computed((): VxeGridProps['columns'] => [
{ type: 'checkbox', width: 60 },
{
field: 'username',
title: $t('ui.column.username'),
minWidth: 80,
},
{
field: 'nickName',
title: $t('ui.column.nickName'),
minWidth: 130,
},
...
]

@anncwb anncwb closed this as completed Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants