映射到对象会给出错误标识符。 ts(1003) 使用密钥时

Mapping over object gives error Identifier expected. ts(1003) when using key

我在它的父组件中有这个对象,我将它传递给子组件然后映射它然后在我映射之后我尝试使用 otherPokemon.base.[key] 这给了我一个错误就在这段时间之后。 这是对象:

{
    pokemon1: {
        name: "Pikachu",
        image: "https://raw.githubusercontent.com/Purukitto/pokemon-data.json/master/images/pokedex/thumbnails/025.png",
        description: "While sleeping, it generates electricity in the sacs in its cheeks. If it\u2019s not getting enough sleep, it will be able to use only weak electricity.",
        base: {
            "HP": 35,
            "Attack": 55,
            "Defense": 40,
            "SpAttack": 50,
            "SpDefense": 50,
            "Speed": 90,
        },
    },
    pokemon2: {
        name: "Squirtle",
        image: "https://raw.githubusercontent.com/Purukitto/pokemon-data.json/master/images/pokedex/thumbnails/007.png",
        description: "Squirtle\u2019s shell is not merely used for protection. The shell\u2019s rounded shape and the grooves on its surface help minimize resistance in water, enabling this Pok\u00e9mon to swim at high speeds.",
        base: {
            "HP": 44,
            "Attack": 48,
            "Defense": 65,
            "SpAttack": 50,
            "SpDefense": 64,
            "Speed": 43
        },
    }
}

然后在子组件中:

<List component="div" disablePadding>
          {Object.entries(pokemon.base).map(([key, value]) => {
            console.log(otherPokemon.base.[key])
            return(
            <ListItem>
                <ListItemText>{key + ": "}<span className={value > otherPokemon.base.[key] ? classes.more : classes.less}>{value}</span></ListItemText>
            </ListItem>)
          })}
        </List>

代码确实有效,但文件变成红色,错误位有红色下划线:

任何帮助将不胜感激:)

多亏了 Patfreeze 问题解决了错误是我在代码中多了一个句点: //原创

otherPokemon.base.[key]

//固定

otherPokemon.base[key]