图像有时不会显示在Angular2

时间:2016-03-14 04:16:26

标签: angular angular2-routing

我有一张图片<img src="image.png">

当我使用this._router.navigate(['/Home']);时,有时会显示页面中的图像。相反,它显示如下:

enter image description here

我试图改变这个:

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

但它不起作用。什么可能导致这种情况?感谢

1 个答案:

答案 0 :(得分:4)

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

将其用作头后的第一行。

之后根据/ path(html文件)的服务器路径使用图像路径。不要使用HashStrategy!