【发布时间】:2021-02-10 20:50:17
【问题描述】:
我正在尝试在我的 SharePoint spfx Web 部件解决方案中使用 Microsoft Graph Toolkit,更具体地说是 React 版本 (@microsoft/mgt-react)。
我已经成功导入了包,并且还正确地渲染了控件。
但是,我现在尝试根据控件的结果来呈现控件。像这样的:
const MyPerson = (props: MgtTemplateProps) => {
const { person } = props.dataContext;
return <Person userId={person.userPrincipalName}></Person>;
}
这里是控件:
<Get resource={`/groups/${this.props.groupid}/members`}>
<MyPerson template="value" />
</Get>
没有渲染出来。 有人可以帮我解决这个问题吗?
谢谢!
更新的工作样本:
public render(): React.ReactElement<IMemberListProps> {
const LoadingPerson = (props: MgtTemplateProps) => {
return <div><Spinner size={SpinnerSize.large} label="Loading members..." /></div>;
};
const MemberPerson = (props: MgtTemplateProps) => {
const person = props.dataContext;
return <div className={styles.memberRow}>
<Person userId={person.userPrincipalName} view={PersonViewType.twolines} fetchImage={true} showPresence={true}
personCardInteraction={PersonCardInteraction.hover} line2Property="mail"></Person></div>;
};
return (
<div>
<Get resource={`/groups/${this.props.groupId.toString()}/members/microsoft.graph.user/?$count=true&$orderby=displayname`} >
<MemberPerson template="value" />
<LoadingPerson template="loading" />
</Get>
</div>
);
}
【问题讨论】:
标签: reactjs templates sharepoint spfx microsoft-graph-toolkit