我在我的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版本,但问题依然存在。
发布于 2022-11-23 16:44:08
@杂音--我正在经历同样的问题。我将从我的解决方案中发布一些代码。
`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 {
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
})
],
}
],
}
],
};}
https://stackoverflow.com/questions/71657755
复制相似问题