我是 React js 的新手。我想为三元表达式中的文本创建键。
import {useTransaltion} from "react-i18next"
function dummy(){
const {t} = useTranslation();
<Typography color="white" variant="h4">
{restartLoading ? <LinearProgress /> : "Restart"}
</Typography>
Run Code Online (Sandbox Code Playgroud)
我该如何翻译“重新启动”..因为以下代码给了我一个错误:
<Typography color="white" variant="h4">
{restartLoading ? <LinearProgress /> : {t("Restart")}}
</Typography>
Run Code Online (Sandbox Code Playgroud)
{t("Restart")} :这里有错误:需要标识符。提前致谢。
当您在三元组内部定义一个大括号时,您不需要再次使用大括号,您可以将 javascript 用作普通的单行代码。
<Typography color="white" variant="h4">
{restartLoading ? <LinearProgress /> : t("Restart")}
</Typography>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1064 次 |
| 最近记录: |