Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
How to get load event in Pictures same as images?

Is it possible to add onload event to picture.

Eg code for images in vue.js

<img src="../../assets/hero-mobile.png" alt="Banner" @load="loaded"/>

the methods is triggered when image loaded.

I have tried to add load event for picture but its not working. Is there any way checking the image is loaded or not ?

<picture class="banner-images" @load="loaded">
      <source media="(min-width:992px)" srcset="../../assets/hero-web.png" />
      <source media="(min-width:768px)" srcset="../../assets/hero-tablet.png" />
      <source media="(min-width:576px)" srcset="../../assets/hero-mobile.png" />
      <img src="../../assets/hero-mobile.png" alt="Banner" @load="loaded"/>
</picture>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Only set @load on img tag:

new Vue({
  el: "#demo",
  data() {
    return {
      isImageLoaded: false,
    }
  },
  methods: {
    loaded() {
      this.isImageLoaded = true
      console.log('>>loaded', this.isImageLoaded)
    },
  },
  watch: {
    isImageLoaded(newValue, oldValue) {
      console.log("New value is: " + newValue)
      console.log("Old value is: " + oldValue)
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div>
    <picture class="banner-images">
      <source media="(min-width:992px)" srcset="https://picsum.photos/992" />
      <source media="(min-width:768px)" srcset="https://picsum.photos/768" />
      <source media="(min-width:576px)" srcset="https://picsum.photos/576" />
      <img src="https://picsum.photos/200" alt="Banner" @load="loaded" />
    </picture>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!