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

276
Views
Object is possibly 'undefined' in Vue with this.$refs

I switched to typescript and suddenly some of my codes are having errors with:

Object is possibly 'undefined'

The typescript version is 3.2.1

Here's the code:

this.$refs[`stud-copy-${index}`][0].innerHTML = 'Link Copied'

I've tried to add an if condition to check if it's undefined but no luck:

if (this.$refs[`stud-copy-${index}`] !== undefined) {
  this.$refs[`stud-copy-${index}`][0].innerHTML = 'Link Copied'
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Can you try this

(this.$refs[`stud-copy-${index}`] as HTMLElement[])[0].innerHTML = 'Link Copied'
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!