【发布时间】:2022-02-10 17:55:38
【问题描述】:
-允许用户更改语言的选择表单不适用于 onclick 我如何使用 onChange 处理程序
- 我正在使用 react i18next。
*请记住,没有收到任何错误或警告。 这是我的代码
import i18n from 'i18next';
export default function Footer() {
const languages = [
{
code: "fr",
name: "francais",
countryCode:"fr"
},
{
code: "en",
name: "english",
countryCode:"gb"
},
{
code: "ar",
name: "العربية",
countryCode:"sa"
}
]
return <Form.Select aria-label="Default select example" >
{languages.map(({code,name, countryCode})=>{
return(
<option key={countryCode} onClick={()=> i18n.changeLanguage(code)}>{name}</option>
)
})}
</Form.Select>
}
【问题讨论】:
-
你能提供一个可重现的例子吗,可能是在codesandbox或类似的地方?