亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

React Lingui - 翻譯輸入占位符

React Lingui - 翻譯輸入占位符

慕容708150 2023-02-17 17:21:58
我對輸入的翻譯道具有疑問placeholder。我有一個包裝器組件<Text />,它呈現<input>一個。我試過這樣翻譯 placholder:import { Trans, t } from '@lingui/macro'const passwordPlaceholder = t('password.placeholder')`Enter password`// this doesn't works<Text as='input' type='password' name='password' placeholder={t(passwordPlaceholder)} required />// neither<Text as='input' type='password' name='password' placeholder={<Trans id={passwordPlaceholder} />} />// not<Text as='input' type='password' name='password' placeholder={passwordPlaceholder} />我嘗試了很多時間來解決這個問題,沒有找到解決方案......
查看完整描述

1 回答

?
拉風的咖菲貓

TA貢獻1995條經驗 獲得超2個贊

該解決方案是由我的前同事建議的,使用帶有對象參數的渲染函數包含“翻譯”屬性。我希望這個答案對某人有所幫助。


    <Trans id={passwordPlaceholder} render={({translation}) => (

     <Text as='input' type='password' name='password' placeholder={translation} required />)} 

/>


查看完整回答
反對 回復 2023-02-17
  • 1 回答
  • 0 關注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號