chore: add image loading error handling (#532)

This commit is contained in:
BiggerRain
2024-04-16 14:02:02 +08:00
committed by GitHub
parent afd8feaa33
commit 405b6a693c
4 changed files with 9 additions and 1 deletions

View File

@@ -137,3 +137,10 @@ export function renderPitchContour(options: {
},
});
}
export function imgErrorToDefalut(e: React.SyntheticEvent<HTMLImageElement, Event>) {
const target = e.target as HTMLImageElement;
target.onerror = null;
target.src = "assets/default-img.jpg";
}