I need the ability to perform file cleanup when a client-side web part is deleted from the page. How can I listen for the delete event?

有帮助吗?

解决方案

You should override the Dispose() method on BaseClientSideWebPart. Make sure you call the base implementation as well.

protected dispose(): void
{
  // Do something interesting
  Log.warn("HelloWorld", "Cleaning up my stuff", this.context.serviceScope);

  // call the base class.
  super.dispose();
}

Note however, there there is a currently a bug where this code doesn't necessarily get called. That will be fixed.

许可以下: CC-BY-SA归因
scroll top