【问题标题】:Failed to load resource: net::ERR_FILE_NOT_FOUND but data is loaded加载资源失败:net::ERR_FILE_NOT_FOUND 但数据已加载
【发布时间】:2018-12-07 12:33:14
【问题描述】:

enter image description here我有一些错误。这是我的代码。 文件html:

<div ng-controller="newsCtrl">
  <div class="row">
    <div ng-repeat="x in news">

      <div class="col-xs-6">
        <div class="newsContent">{{x.content}}</div>
        <div class="newsImage"><img src="../image/{{x.image}}" alt="vinfast oto"></div>
        <div class="newsTitle">
          <h2>{{x.title}}</h2>
        </div>
      </div>
      <hr>
    </div>
  </div>
</div>

文件 app.js:

app.controller("newsCtrl", function ($scope, $http) {
  $http({
    method: "GET",
    url: "http://localhost:8080/EX11_29112018_spring_restful/news"
  }).then(function (response) {
    $scope.news = response.data;
  })
});

views 文件夹中的 HTML,js 文件夹中的 app.js,它们在 webapp 文件夹中。我的图像已加载,但出现此错误:加载资源失败:net::ERR_FILE_NOT_FOUND; 如何解决。

【问题讨论】:

  • 您是否使用 ng-src 作为&lt;img ng-src="string"&gt;&lt;/img&gt;
  • 好的,非常感谢
  • 它是否适用于更改??
  • 是的,我试过了,效果很好
  • 我会为其他人提供未来的答案,好的!请接受!

标签: java angularjs


【解决方案1】:

ngSrc 指令解决了这个问题。所以改变

<img src="../image/{{x.image}}" alt="vinfast oto">

改正方式为:

<img ng-src="../image/{{x.image}}"></img>

了解更多关于ngSrchere的信息。

【讨论】:

    猜你喜欢
    • 2015-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 2018-11-07
    • 2023-03-29
    • 2014-06-24
    相关资源
    最近更新 更多