在这个render函数中,我从SharePoint中的列表中检索数据并呈现fileContent
,但属性没有从listItems
中替换
下面是我尝试的render函数的代码:
public render(): React.ReactElement<ILinkItemsWithReactProps> {
return (
<div className={styles.linkItemsWithReact}>
<ol>
{this.state.listitems.map((listitem, listitemkey) => {
console.log(this.state.listitems);
return (
<li key={listitemkey}>
<a>{this.state.fileContent}</a>
</li>
);
})}
</ol>
</div>
);
}
字符串
我想渲染一个特定模板的fileContent
,并从listItems
的实际数据中显示该模板的属性。
2条答案
按热度按时间vmpqdwk31#
您没有使用map回调提供的值,而是使用了其他一些状态。
如果将
listitem.content
中的content
替换为正确的属性,则以下代码应该可以工作。另外,Array.prototype.map()回调函数的第二个参数是数组中的
index
,所以我也改变了它。字符串
tkqqtvp12#
看起来像是在
this.state.listitems
上迭代,但除了作为关键属性之外,没有使用它们。你的意思是在循环中渲染
listitem.fileContent
或类似的东西吗?