react hooks img 显示默认图片

图片不存在或者路径不存在

import defaultImg from "./default.jpg";
const { picUrl} = props.item;
const [imgSrc, handleImageErrored] = useState(picUrl);
<img onError={() => handleImageErrored(defaultImg)} src={imgSrc} />

原文地址:https://www.cnblogs.com/yixiaoyang-/p/14667422.html