我正在开发一个板球API,因为团队名称被写成team-1,我认为这不是在对象上定义属性的有效格式。
检查我提供的图像。
我试过这些方法
<h3 class="display-6 text-center"> ${eachItem["team-1"]} VS ${eachItem.team-1} </h3>但是我还是收到了一个错误

发布于 2021-07-03 23:35:04
eachItem"team-1“这应该没问题。如果不是,可能是另一个问题。
const hero = {
"spider-man" : 1
}
console.log(hero["spider-man"])
发布于 2021-07-04 00:06:56
eachItem.team-1就像在做x - 1。点优先。
eachItem["team-1"]和eachItem["team-2"]应该可以为您工作。
https://stackoverflow.com/questions/68237579
复制相似问题