Fehlermeldung:
error TS2339: Property web does not exist on type
SPRest.
Fehlermeldung
in VS Code
[20:02:53] Error - [tsc]
src/webparts/webPart01/WebPart01WebPart.ts(123,8): error TS2339: Property
'web' does not exist on type 'SPRest'.
[20:02:53] Error - 'tsc' sub task errored after
1.37 s
exited with code 2
|
Lösung:
Man muss zuvor den Import anpassen und onInit() für den
SharePoint Context ausführen
Im Import-Bereich folgende Zeile einfügen
//import { sp } from "@pnp/sp";
import { sp } from "@pnp/sp/presets/all"; //*pnpjs->context
|
Einfach die Methode onInit() einfügen
protected onInit(): Promise<void> {
//----< onInit() >----
//*pnp/sp: get sp context
return super.onInit().then(_ => {
// other init code may be present
sp.setup({
spfxContext: this.context
});
});
//----</ onInit() >----
}
|
Fehlermeldung in VS Code