arrays - “字符串”类型上不存在属性“地图”
问题描述
我使用 .map() 函数遍历我的数组,代码按预期工作,但出现以下 TS 错误:
类型“字符串”.ts(2339) 上不存在属性“地图”
Data of the book.benefitsBlock array = ["old", "roman", "nice", "funny"]
<Benefits>
{book.benefitsBlock.map((book) => (
<Benefit key={book}>{book}</Benefit>
))}
</Benefits>
解决方案
推荐阅读
- bootstrap-4 - Bootstrap 4 - 对齐
- python - 带有命名空间的 XML 到 Pandas DF - Python
- c - c - 只有当所有孩子都被终止时,waitpid() 和 co 才检测到孩子的终止吗?
- sql - 使用字符串列旋转 SQL 表的语法错误
- sql - Upsert 查询未更新 postgres 中的记录
- c++ - 如何更改 unit_test/修复纯函数错误
- mysql - 如何在 SQL 中连接数据库中的两个表?
- excel - 更改参考
- python - 使用 selenium 在 Python 中使用安全令牌而不是密码
- sql-server - 在链接的 SQL Server 上运行 Oracle DB 函数时出错