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

167
Views
¿Por qué funciona el primer método pero el segundo no?

Primer método:

 const getWeatherIcon = (iconParameter) => { const icon = `https://openweathermap.org/img/wn/${iconParameter}@2x.png` return <img src={icon} alt={iconParameter} /> }

 <div className="weathericon"> {getWeatherIcon(weather.weather[0].icon)} //Ex: weather.weather[0].icon=50n </div>

Segundo método:

 const getWeatherIcon = (iconParameter) => { const icon = `assets/weather/${iconParameter}.svg` return <img src={icon} alt={iconParameter} /> }

 <div className="weathericon"> {getWeatherIcon(weather.weather[0].main)} //Ex: weather.weather[0].main=Haze </div>

Aquí está mi directorio de proyectos

 src │ App.js │ index.css │ index.js │ └───assets └───weather | | Haze.svg │ | Clear.svg │ | Rain.svg | └───bg | file111.png | file112.png

Ignorar seguimiento

Parece que tu publicación es principalmente código; por favor agregue algunos detalles más. Parece que tu publicación es principalmente código; por favor agregue algunos detalles más. Parece que tu publicación es principalmente código; por favor agregue algunos detalles más. Parece que tu publicación es principalmente código; por favor agregue algunos detalles más.

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

0

La ruta de su archivo no es correcta, intente usar ./assets/weather para proporcionar la ruta adecuada

about 4 years ago · Juan Pablo Isaza Report

0

¡¡Esto funcionó!!

 const getWeatherIcon = (iconParameter) => { const icon = `${iconParameter}.svg` return < img src={icon} alt={iconParameter} width='100px' /> }

 <div className="weathericon"> {getWeatherIcon(weather.weather[0].main)}//Haze, Clear etc. </div>

Sistema de archivos:

 src │ App.js │ index.css │ index.js │ └───assets │ └───bg │ | file111.png │ | file112.png │ │ public │ Clear.svg │ Clouds.svg │ Rain.svg │ Haze.svg
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!