简体   繁体   English

如何生成作者链接 - Spfx/React 和 Sharepoint 2019?

[英]How to generate Link to Author - Spfx/React and Sharepoint 2019?

I am pretty new at working with Sharepoint (2019) & React, so my question is:我对使用 Sharepoint (2019) 和 React 还很陌生,所以我的问题是:

My goal is to develop a webpart, which basically shows entrys from a list in a more fancy way.我的目标是开发一个 webpart,它基本上以更奇特的方式显示列表中的条目。 First of all, i got all the items from that list:首先,我从该列表中获得了所有项目:

await sp.web.lists.getByTitls(this.properties.listName).items.select("Title", "Description", "Location", "Location/Title", "Location/ID", "Author", "Author/Title").expand("Location", "Author").orderBy(...

I store each value in a variable, for example authorName: item.Author.Title then return for each entry a section, in which i display for example: <div className={classNames(styles.Column, styles.Section)}>{item.authorName}</div>我将每个值存储在一个变量中,例如 authorName: item.Author.Title 然后为每个条目返回一个部分,我在其中显示例如: <div className={classNames(styles.Column, styles.Section)}>{item.authorName}</div>

Now i want to generate a link from that item.authorName to the actual SharePoint User, so that anyone can see his/her contact infos.现在我想生成一个从 item.authorName 到实际 SharePoint 用户的链接,以便任何人都可以看到他/她的联系信息。 How this is be done - what is the best approve?这是如何完成的 - 最好的批准是什么? Caml Query?骆驼查询? I tried a few things but nothing worked fine for me, now I am a little desperated.我尝试了一些东西,但对我来说没有任何效果,现在我有点绝望。 I am using SharePoint 2019 & React.我正在使用 SharePoint 2019 和 React。 Would be so thankful for any help!非常感谢您的帮助!

you can use for example:你可以使用例如:

  1. Pnp Spfx controls - https://pnp.github.io/sp-dev-fx-controls-react/controls/fields/FieldUserRenderer/ Pnp Spfx 控件 - https://pnp.github.io/sp-dev-fx-controls-react/controls/fields/FieldUserRenderer/

    import { FieldUserRenderer } from "@pnp/spfx-controls-react/lib/FieldUserRenderer";从“@pnp/spfx-controls-react/lib/FieldUserRenderer”导入 { FieldUserRenderer };

  2. Pnp Js Library: https://pnp.github.io/pnpjs/sp/site-users/ to get user properties and then render your own information Pnp Js 库: https ://pnp.github.io/pnpjs/sp/site-users/ 获取用户属性,然后渲染自己的信息

I can recommend to use Pnp spfx controls (for SharePoint 2019 - use version 1.XX, the latest is 1.20 now)我可以推荐使用 Pnp spfx 控件(对于 SharePoint 2019 - 使用版本 1.XX,现在最新的是 1.20)

If you need any additional support do not hesitate to contact me - my environment is also Sharepoint 2019.如果您需要任何其他支持,请随时与我联系 - 我的环境也是 Sharepoint 2019。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM