首页 > 解决方案 > “字符串”类型上不存在属性“地图”

问题描述

我使用 .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>

标签: arraysreactjstypescript

解决方案


推荐阅读