首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PNP PeoplePicker类型“WebPartContext”缺少“BaseComponentContext”类型中的下列属性

PNP PeoplePicker类型“WebPartContext”缺少“BaseComponentContext”类型中的下列属性
EN

Stack Overflow用户
提问于 2022-03-29 07:04:17
回答 1查看 1.3K关注 0票数 0

我在我的spfx反应webpart解决方案中使用spfx Peoplepicker控件,但是Peoplepicker控件遇到了下面的错误。

错误:类型'WebPartContext‘缺少’BaseComponentContext‘类型中的下列属性:_isServedFromLocalhost,isServedFromLocalhostts(2739) IPeoplePicker.d.ts(14,5):预期类型来自在'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>’类型上声明的属性'context‘

在这里输入图像描述

请评论&如果需要更多的信息,请告诉我。

在解决方案中,我使用的是spfx 1.11.0版本,并尝试了不同的spfx 1.10.0版本,但问题依然存在。

EN

回答 1

Stack Overflow用户

发布于 2022-11-23 16:44:08

@杂音--我正在经历同样的问题。我将从我的解决方案中发布一些代码。

代码语言:javascript
复制
`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;
  }`

受保护的getPropertyPaneConfiguration():IPropertyPaneConfiguration {

代码语言:javascript
复制
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
            })
          ],
        }
      ],
    }
  ],
};

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71657755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档