Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用Angular 7[src]属性获取404 null错误_Html_Angular - Fatal编程技术网

Html 使用Angular 7[src]属性获取404 null错误

Html 使用Angular 7[src]属性获取404 null错误,html,angular,Html,Angular,我正在尝试在Angular应用程序中使用[src]属性加载图像。当我直接加载时,图像内容在外部呈现良好。然而,应用程序给了我404空错误 HTML- <span class="pull-right"> <img [src]="sampleImage" alt="{{ user.firebaseuser.displayName }}" class="img-responsive" st

我正在尝试在Angular应用程序中使用[src]属性加载图像。当我直接加载时,图像内容在外部呈现良好。然而,应用程序给了我404空错误

HTML-

<span class="pull-right">
        <img
          [src]="sampleImage"
          alt="{{ user.firebaseuser.displayName }}"
          class="img-responsive"
          style="max-height: 50px;">
</span>
错误详细信息-

http://localhost:4200/null 404 (Not Found)

我在这里遗漏了什么?

使用[attr.src]=。。。相反如果该值为null,它将不会添加src,并将阻止本地主机调用null。

使用[attr.src]=。。。相反如果值为null,它不会添加src,并且会阻止本地主机调用null。

您能在Stackblitz中重新创建它吗?我已经测试了上面的代码,它在我的应用程序中运行良好。这个alt={{user.firebaseuser.displayName}}可能会破坏你的代码。你能在Stackblitz中重新创建它吗?我已经测试了上面的代码,它在我的应用程序中运行良好。这个alt={{user.firebaseuser.displayName}}可能是破坏了您的代码。
http://localhost:4200/null 404 (Not Found)