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

299
Views
vue.js ReferenceError (cuando se usa el evento de cambio de tamaño)

Estoy tratando de obtener la altura de la ventana al cambiar el tamaño, pero sigo recibiendo el error ReferenceError: calcOfSliderHeight is not defined .

¿Alguien podría decirme qué está pasando? Aquí está mi código

 let example = new Vue({ el: '#example', data() { return { pageIndex: 2, posTop: 0, posTop2: 0, } }, methods: { calcOfSliderHeight() { let _this = this; _this.posTop = (_this.pageIndex - 1) * window.innerHeight }, calcOfSliderHeight2() { let _this = this; _this.posTop2 = (_this.pageIndex - 3) * window.innerHeight }, }, mounted: function() { let _this = this; window.addEventListener('resize', function() { calcOfSliderHeight() calcOfSliderHeight2() }); _this.posTop = calcOfSliderHeight(); _this.posTop2 = calcOfSliderHeight2(); } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe llamar a calcOfSliderHeight con this palabra clave, por lo que sería:

 window.addEventListener('resize', () => { this.calcOfSliderHeight() this.calcOfSliderHeight2() });

Ref: https://vuejs.org/guide/essentials/reactivity-fundamentals.html#declaring-methods

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!