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

169
Views
El método Number () no me da la salida adecuada

Estoy creando un proyecto React que incluye imágenes. En mi proyecto, quiero obtener el ancho y el alto de la imagen que se cargó. Para eso estoy usando

 const image = document.getElementById("inputimage"); const width = Number (image.width); const height = Number (image.height); console.log( width, height );

Etiqueta de imagen en otra página

 <img id='inputimage' alt='image' src={imageUrl} width="500px" height="auto" />

Aquí Number() se usa para convertir image.width e image.height en números para futuros cálculos. Cada vez que ejecuto este código no obtuve el resultado.

 const image = document.getElementById("inputimage"); const width = image.width; const height = image.height; console.log( width, height );

Pero cuando elimino Number() , obtuve resultados.

¿Alguien sabe por qué no obtuve resultados cuando se usa Number() ? ¿Hay algo que pueda hacer para convertir image.width e image.height en números?

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

0

Creo que puedes usar parseInt(image.width) (o image.height ).

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!