Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List SPFx-无法从SP列表中读取人员字段_List_Sharepoint_Field_Spfx - Fatal编程技术网

List SPFx-无法从SP列表中读取人员字段

List SPFx-无法从SP列表中读取人员字段,list,sharepoint,field,spfx,List,Sharepoint,Field,Spfx,我正在尝试从SharePoint中的“人员”字段获取数据。我的代码总是返回8行(正确),但在由Person组成的项目中,它返回[object Obejct]。 导出接口SPUser{ 普拉科夫尼克:弦; } . . 私有getListData():void{ 这是._getListData()。然后((响应)=>{ 此._renderList(响应); }); } private _renderList(项目:SPUser[]):void{ 让html:string=''; html+=`T

我正在尝试从SharePoint中的“人员”字段获取数据。我的代码总是返回8行(正确),但在由Person组成的项目中,它返回[object Obejct]。

导出接口SPUser{
普拉科夫尼克:弦;
}
.
.
私有getListData():void{
这是._getListData()。然后((响应)=>{
此._renderList(响应);
});
}
private _renderList(项目:SPUser[]):void{
让html:string='';
html+=`Title`;
items.forEach((item:SPUser)=>{
如果(item.Pracovnik!=null){
html+=`
${item.Pracovnik}
`};
});
html+=`;
常量listContainer:Element=this.domeElement.querySelector(“#spGetListItems”);
listContainer.innerHTML=html;
}
私有异步\u getListData():承诺{
返回pnp.sp.web.lists.getByTitle(“org_struktura”).items.select(“Pracovnik/ID”).expand(“Pracovnik”).get()。然后((响应)=>{
返回响应;
});
}
公共呈现():void{
this.doElement.innerHTML=`
`;  
这是.getListData();

}
将SharePoint列表项映射到类型对象的示例演示

export interface IReactItem{ 
  Id:number,
  Title:string,
  Description:string,
  User:{ID:number,EMail:string},
  enableEdit:boolean
}

private async _getListData(): Promise<IReactItem[]> {
  return pnp.sp.web.lists.getByTitle("TestList").items.select("Id,Title,Description,User/ID,User/EMail").expand("User").get().then((response:IReactItem[]) => {
    return response;
  });
}
导出接口i活动项{
身份证号码:,
标题:字符串,
描述:字符串,
用户:{ID:number,EMail:string},
启用编辑:布尔值
}
私有异步\u getListData():承诺{
返回pnp.sp.web.lists.getByTitle(“TestList”).items。选择(“Id、标题、说明、用户/Id、用户/EMail”)。展开(“用户”).get()。然后((响应:IRActivItem[])=>{
返回响应;
});
}

太棒了!它需要8小时的睡眠,你回答得很好,谢谢!工作起来很有魅力。