Image sometimes does not show in Angular2

十年热恋 提交于 2020-02-08 04:18:30

问题


I have an image <img src="image.png">.

When I use this._router.navigate(['/Home']);, sometimes, the image in the page won't show. Instead it shows like this:

I tried to change to this:

this._ngZone.run(() => {
    this._router.navigate(['/Home']);
});

But it does not work. What can potentially cause this? Thanks


回答1:


<head>
  <base href="/">
  ...
</head>

Use that as the first line after head.

After that use the paths of image as per the server path of the / path(html file). Dont use HashStrategy!



来源:https://stackoverflow.com/questions/35979443/image-sometimes-does-not-show-in-angular2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!