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

130
Views
Why vue computed property doesn't become reaective?

Some part of my script setup:

    const storyVideo = ref("storyVideo")
    const topBar = computed(() => {
        return 'background-position: ' + (storyVideo?.value?.currentTime / store.instagram.story[store
            .currentStory].duration) * 100 + '% 0;'
    })

storyVideo is a video element with ref="storyVideo" and store points to Pinia store

I assigned it to an element using :style="topBar"

The element style is always background-position: 0% 0; but the variables used in the function change

I tried to log what is returned in this function using a @click and console.log and everything looks properly in logs:

background-position: 9.07100199071002% 0;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like your trying to access the element too early, check the documentation https://vuejs.org/guide/essentials/template-refs.html#accessing-the-refs

Note that you can only access the ref after the component is mounted. If you try to access input in a template expression, it will be null on the first render. This is because the element doesn't exist until after the first render!

If you are trying to watch the changes of a template ref, make sure to account for the case where the ref has null value:

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!