el-image onload觸發問題

不刷新頁面,只更新數據不觸發onload事件,因爲緩存,所以給返回的圖片加上時間戳 + ‘?_=’ + new Date().getTime()

獲取圖片的寬高:

<el-image fit="cover" @load="handleLoadImage(row, $event)" :src="row.docUrl"></el-image>

handleLoadImage(row: BannerInfo, event: any) {
  console.log('--------------------------', row)
  const size = `${event.currentTarget.naturalWidth}px * ${event.currentTarget.naturalHeight}px`
  this.$set(row, 'size', size)
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章