Javascript 如何修复404(未找到)的角度

Javascript 如何修复404(未找到)的角度,javascript,angular,Javascript,Angular,我得到了一个错误404,它没有找到 在我的html中 list.component.html <img src="./assets/icons/weather/{{ weatherClass?.img }}.svg" width="130px" /> list.componen.ts export class Weather { constructor( public locName: string, public temp: string

我得到了一个错误404,它没有找到

在我的html中

list.component.html

 <img src="./assets/icons/weather/{{ weatherClass?.img }}.svg" width="130px" />
list.componen.ts

export class Weather {
    constructor(
        public locName: string,
        public temp: string,
        public img: string,
        public type:string,
        public tempMin:string,
        public tempMax:string,
        public countryName: string,
        public sunrise: string,
        public sunset: string) {}
}
this.weatherService.currentLocation(this.lat, this.lon).subscribe(data => {

        let sunset = format(new Date(data.sys.sunset * 1000), 'hh:mm a');
        this.weatherClass = new Weather(
          data.name,
          data.main.temp,
          data.weather[0].icon,
          data.weather[0].description,
          data.main.temp_max,
          data.main.temp_min,
          data.sys.country
        );
        return this.weatherClass;
      });

您不能从observable返回
this.weatherClass
。您可以在图像初始化后显示它,而不是它

<img *ngIf="weatherClass" src="{{ './assets/icons/weather/' + weatherClass.img + '.svg' }}" width="130px" />

您不能从observable返回
this.weatherClass
。您可以在图像初始化后显示它,而不是它

<img *ngIf="weatherClass" src="{{ './assets/icons/weather/' + weatherClass.img + '.svg' }}" width="130px" />


您在
img
上添加了
*ngIf
指令了吗?对不起,先生,我忘了添加
*ngIf
。非常感谢你!您在
img
上添加了
*ngIf
指令了吗?对不起,先生,我忘记添加
*ngIf
。非常感谢你!