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

364
Views
Nuxt - getter for window innerwidth does not update

Our project uses class based components. I have a getter to get the window innerWidth, but the value is only set once, it doesn't update if I change the window width.

get viewPortWidth() {
  
    if (process.client) {
          if (window.innerWidth !== undefined && window.innerHeight !== undefined) {
            return window.innerWidth;
          } else {
            return document.documentElement.clientWidth;
          }
        }
        return false; 
  }

If I write the value in the html: {{viewPortWidth}} it doesn't change. The value is the same also in vue devtools. Aren't getters supposed work like computed properties? How can I get to update seamlessly?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

vue computed properties are cached based on their reactive dependencies. window.innerWidth not a reactive dependency.

you can track changing window size event by adding an event listener in your "created" lifecycle hook like this:

created(){window.addEventListener('resize', (e)=>{console.log(e)})}
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!