如果可能的话,显示代码更容易解释我在寻找什么。
validations.js
文件
export const required = 'REQUIRED'
export const email = 'NEEDS_TO_BE_EMAIL'
translations.js
文件
import { required as requiredValidation, email as emailValidation } from './validations'
export const { [requiredValidation], [emailValidation] } = defineMessages({
[requiredValidation]: {
id: `validations.${requiredValidation}`,
description: 'Mensagem de obrigatoriedade do campo',
defaultMessage: '{field} é obrigatório'
},
[emailValidation]: {
id: `validations.${emailValidation}`,
description: 'Mensagem de formato de email do campo',
defaultMessage: '{field} precisa ser do tipo e-mail'
}
})
我想导出const,它是:
REQUIRED
和NEEDS_TO_BE_EMAIL
,有什么方法吗?
感谢进步!
答案 0 :(得分:1)
据我所知这是不可能的。但是,这就是您可以做的。不过,您可以使用动态生成的键导出单个对象:
let obj = {};
obj[fooLabel] = fooValue;
export default obj;