自定义组件刷新标准相关列表
背景
有一个上传图片的自定义LWC组件,嵌套在记录页Flexipage里,用户可以复制并粘贴图片上载到记录的Attachment相关列表。
需要解决的问题:图片上传后,需要自动刷新相关列表,展示上传的图片。
方案
import { LightningElement } from "lwc";
import { RefreshEvent } from 'lightning/refresh';
export default class ImagePaster extends LightningElement {
// if img upload & associate with attachment of record successfully -> call following js method.
// this.handleUploadFinished();
handleUploadFinished() {
// refresh the standard related list
this.dispatchEvent(new RefreshEvent());
}
}