1
我使用此代碼加載圖像手柄圖像加載在陣營
{Image} from 'react-bootstrap';
<Image src={res.imgUrl} className={styles.image} onError={(e)=>{e.target.src="/defaultImage.png"}} responsive thumbnail />
<Label bsStyle="primary" className={styles.price}}>{Price} €</Label>
下面是標籤
.price {
position: absolute;
top: 0;
right: 0;
font-size: 0.95em;
}
它工作正常的CSS代碼。但在加載期間,「標籤」 - 元素顯示不太好,因爲沒有圖像尚未加載,也沒有足夠的位置顯示出來。
有沒有一個很好的解決方案呢?
謝謝!
PS:它看起來像這樣加載
你好,非常感謝。我希望有一種方法可以使用alt屬性。但這個解決方案工作正常。在我的示例中,我必須添加{this.state.didLoad && }麻煩了。操作樣式並不能很好地工作,因爲我使用react-bootrstrap,它會覆蓋圖像組件的完整樣式。 – MichaelRazum