reactjs - 返回内部功能组件中的显示值
问题描述
我尝试从对象中填充值
我的对象
{
"title": 5
"value": 6
"second": "2019-03-06"
}
我的渲染部分。它在地图和 foreach 中都显示错误
{newAttributes.forEach((data) => {
<React.Fragment>
<label > {data.title} </label>
<label >{data.value} -</label>
<label > {data.second} </label>
</React.Fragment>
})}
在地图中,我尝试了除键之外的其他值,我无法获得其他值
{Object.keys(newAttributes).map((key) => (
<React.Fragment>
<label > {newAttributes.title} </label>
<label >{newAttributes.value} -</label>
<label > {newAttributes.second} </label>
</React.Fragment>
))}
解决方案
我猜你错过了从地图返回一个值以及你访问属性的方式
{
Object.keys(newAttributes).map((data) => {
return <label> {newAttributes[key]} </label>
})
}
推荐阅读
- reportbuilder - Reporting Services 本地找不到程序集
- swift - RealityKit – transform.rotate() 使对象的规模更大
- python - 基于多列更新 NaN 列(带字符串)
- java - 如何将文本文件的内容转换为单个变量?(爪哇)
- oop - Common Lisp 对象系统中的通用调度与经典 OOP 中的动态调度相同吗?
- fortran - 在其他语言中是否有类似的“COMMON”(来自 Fortran 的引用环境)的实现?
- reactjs - 将 android:usesCleartextTraffic 更改为 false
- javascript - 检查更改编号是否已更改刷新页面
- android - Kotlin - 如何从对话框中的按钮选择中获取价值?
- python - ValueError: 层序贯_1 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。收到的完整形状:(无,93)