【发布时间】:2021-12-08 07:16:49
【问题描述】:
我在 SPFx Web 部件中有一个异步函数,它从 SPO 列表中获取数据。
public async getTabData(theList = "ListOfLinks") {
console.log('getTabData');
let web = Web(this.props.webURL);
web.lists.getByTitle("ListOfLinks").items.select(...colsToSelect).get();
const items: any[] = await web.lists.getByTitle(theList).items.get();
console.log('items:' + items);
是否可以从 DetailsList 中调用此函数?
我尝试这样做
<DetailsList
items={this.getTabData(item.ListToShow)}
但它说...
Type 'Promise<any[]>' is missing the following properties from type 'any[]': length, pop, push, concat, and 26 more.ts(2740)
DetailsList.types.d.ts(60, 5): The expected type comes from property 'items' which is declared here on type 'IntrinsicAttributes & IDetailsListProps & { children?: ReactNode; }'
(JSX attribute) IDetailsListProps.items: any[]
谢谢 P
【问题讨论】:
标签: reactjs sharepoint sharepoint-online spfx