【发布时间】:2022-09-23 15:44:41
【问题描述】:
我收到这样的 API 响应。
{
\"message\": \"The password needs at least %1 characters. Password should be having %param2 special characters in it. Create a new password and try again.\",
\"parameters\": [
\"8\",
\"param2test\"
]
}
在这里,我应该搜索响应中是否有 %[string],如果有,我需要将 %1 替换为参数的第一个数组元素,将 %2 替换为第二个,依此类推。可能有 n 个参数。我如何在 React 中做到这一点?
标签: javascript