PNP PeoplePicker类型' webpartcontext'缺少类型' basecomponentContext&#x27的以下属性。

发布于 2025-01-17 15:41:25 字数 610 浏览 1 评论 0原文

我在我的SPFX React WebPart解决方案中使用SPFX PeoplePicker Control,但是PeoplePicker Control遇到以下错误。

错误 : 类型“ WebPartContext”缺少“ BaseComponentContext”类型的以下属性:_ isserved fromlocalhost,Isserved fromlocalhostts(2739) ipeoplepicker.d.ts(14,5):预期类型来自属性“上下文”,该属性在此处声明在类型'intinsiCattributes& amp; IntinsicClassAttributes< peoplepicker> & Readonly< ipeoplepickerprops> & Readonly< ...>'

在此处输入图像描述

请注释&让我知道是否需要任何其他信息。

在解决方案中,我使用的是SPFX 1.11.0版本,并尝试了不同的SPFX 1.10.0版本,但问题保持不变。

I am using spfx Peoplepicker control in my spfx react webpart solution but Peoplepicker control encountering the below error.

Error :
Type 'WebPartContext' is missing the following properties from type 'BaseComponentContext': _isServedFromLocalhost, isServedFromLocalhostts(2739)
IPeoplePicker.d.ts(14, 5): The expected type comes from property 'context' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<PeoplePicker> & Readonly<IPeoplePickerProps> & Readonly<...>'

enter image description here

please comment & let me know if any additional information needed.

In the solution i am using spfx 1.11.0 version and tried different spfx 1.10.0 version but issue remains same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

用心笑 2025-01-24 15:41:25

@murb 我也遇到同样的问题。我将发布我的解决方案中的一些代码。

`export interface IPolicyWebPartProps {
    siteName:string;
    siteCollection: WebPartContext;
    description: string;
    lists: string;
    fields: any[];
    context: WebPartContext;
    listName: string ;
    isConfigured:boolean;
    isChecked:boolean;
    titleText:string;
    themeVariant: IReadonlyTheme | undefined;
    dateSigned: any;
    checkboxLabel:string;
    CheckboxPlaceholder:string;
    hasLicence:boolean;
    baseContext: IPropertyFieldPeoplePickerProps;
  }`

protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {

return {
  showLoadingIndicator:this.loadingIndicator,
  loadingIndicatorDelayTime: 1,
  pages: [
    {
      header: {
        description: strings.PropertyPaneDescription,
      },
      groups: [
        { 
          groupFields: [
            PropertyPaneTextField("titleText", {
              label: strings.Title,
              placeholder: strings.TitlePlaceholder
            }),
            PropertyPaneTextField("description", {
              label: strings.DescriptionFieldLabel,
              multiline:true,
              placeholder:strings.Description
            }),
            PropertyPaneTextField("checkboxLabel", {
              label: strings.CheckboxLabel,
              placeholder: strings.CheckboxPlaceholder
            }),
             PropertyPaneDropdown("siteCollection", {
              label: strings.SiteCollection,
              options: this.siteCollections,
              selectedKey: this.properties.siteName,
              disabled: this.loadingIndicator
            }),
            PropertyPaneDropdown("listName",{
              label: strings.ListFieldLabel,
              options: this.properties.fields,
              disabled: this.isFetched || this.loadingIndicator,
              selectedKey: this.properties.listName,
            }),
            PropertyFieldPeoplePicker('people',{
              label: 'Add people or group to list',
              initialData: this.properties.people,
              allowDuplicate: false,
              principalType: [PrincipalType.Users],
              onPropertyChange: this.onPropertyPaneFieldChanged,
              context: this.context,
              properties: this.properties,
              onGetErrorMessage: null,
              deferredValidationTime: 0,
              key: 'peopleFieldId'
            }),
            PropertyPaneButton("button",{
              onClick:null,
              text:"Save",
              buttonType: PropertyPaneButtonType.Primary
            })
          ],
        }
      ],
    }
  ],
};

}

@murb I am experiencing this same issue. I will post some code from my solution.

`export interface IPolicyWebPartProps {
    siteName:string;
    siteCollection: WebPartContext;
    description: string;
    lists: string;
    fields: any[];
    context: WebPartContext;
    listName: string ;
    isConfigured:boolean;
    isChecked:boolean;
    titleText:string;
    themeVariant: IReadonlyTheme | undefined;
    dateSigned: any;
    checkboxLabel:string;
    CheckboxPlaceholder:string;
    hasLicence:boolean;
    baseContext: IPropertyFieldPeoplePickerProps;
  }`

protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {

return {
  showLoadingIndicator:this.loadingIndicator,
  loadingIndicatorDelayTime: 1,
  pages: [
    {
      header: {
        description: strings.PropertyPaneDescription,
      },
      groups: [
        { 
          groupFields: [
            PropertyPaneTextField("titleText", {
              label: strings.Title,
              placeholder: strings.TitlePlaceholder
            }),
            PropertyPaneTextField("description", {
              label: strings.DescriptionFieldLabel,
              multiline:true,
              placeholder:strings.Description
            }),
            PropertyPaneTextField("checkboxLabel", {
              label: strings.CheckboxLabel,
              placeholder: strings.CheckboxPlaceholder
            }),
             PropertyPaneDropdown("siteCollection", {
              label: strings.SiteCollection,
              options: this.siteCollections,
              selectedKey: this.properties.siteName,
              disabled: this.loadingIndicator
            }),
            PropertyPaneDropdown("listName",{
              label: strings.ListFieldLabel,
              options: this.properties.fields,
              disabled: this.isFetched || this.loadingIndicator,
              selectedKey: this.properties.listName,
            }),
            PropertyFieldPeoplePicker('people',{
              label: 'Add people or group to list',
              initialData: this.properties.people,
              allowDuplicate: false,
              principalType: [PrincipalType.Users],
              onPropertyChange: this.onPropertyPaneFieldChanged,
              context: this.context,
              properties: this.properties,
              onGetErrorMessage: null,
              deferredValidationTime: 0,
              key: 'peopleFieldId'
            }),
            PropertyPaneButton("button",{
              onClick:null,
              text:"Save",
              buttonType: PropertyPaneButtonType.Primary
            })
          ],
        }
      ],
    }
  ],
};

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文