加载资源失败:404(未找到)- Rails 自定义字体

     2023-03-07     33

关键词:

【中文标题】加载资源失败:404(未找到)- Rails 自定义字体【英文标题】:Failed to load resource: 404 (Not Found) - Rails custom fonts 【发布时间】:2014-09-16 10:00:51 【问题描述】:

我正在尝试通过 CSS @font-face 加载一些自定义字体。我正在使用 rails fonts_path 方法。它在我的开发浏览器中成功生成了正确的路径:

/assets/fonts/my_font.eot?#iefix

但是,它将此路径附加到0.0.0.0:3000(rails 开发服务器),可能不是我的 Rails 项目中 /assets/fonts/ 的位置。我不知道 Rails 路由的路线与 Rails 资产之类的东西之间的关系。

这里是错误:

Failed to load resource: the server responded with a status of 404 (Not Found)    http://0.0.0.0:3000/assets/fonts/my_Ffent.woff

这是我的样式表:

<style type="text/css">
@font-face
  font-family:"My Font";
  src:url(<%=font_path('/assets/fonts/my_font.eot?#iefix')%>);
  src:url(<%=font_path('/assets/fonts/my_font.eot?#iefix')%>) format("eot"),url(<%=font_path('/assets/fonts/my_font.woff')%>) format("woff"),url(<%=font_path('/assets/fonts/my_font.ttf')%>) format("truetype"),url(<%=font_path('/assets/fonts/my_font.svg#c1b10d74-5304-41c3-b9de-00f29187df91')%>) format("svg");

</style>

样式表放在application.html.erb 可能是问题的一部分?它在&lt;head&gt; 标签中定义。

【问题讨论】:

你有没有试过这里的解决方案:***.com/questions/10905905/… 【参考方案1】:

查看了我使用@font-face 的代码并以这种方式记录了它。试一试,看看它是否适合你。 如您所见,我仅通过声明其名称来声明字体 src localy。

@font-face 
    font-family: 'yourfont Novum Light';
    src: local('yourfont Novum Light') url("https://cns.xx.com/ux/site/1.1/fonts/yourfont-novum/yourfont-Novum-Light.eot");

font-weight: 400;
font-style: normal

【讨论】:

加载资源失败:服务器响应状态为 404(未找到)

】加载资源失败:服务器响应状态为404(未找到)【英文标题】:Failedtoloadresource:theserverrespondedwithastatusof404(NOTFOUND)【发布时间】:2013-03-3003:23:16【问题描述】:我是uisngpython,要将数据从json文件显示到页面,我收到以下错误Fail... 查看详情

Apache Cordova:“加载资源失败:服务器响应状态为 404(未找到)”

】ApacheCordova:“加载资源失败:服务器响应状态为404(未找到)”【英文标题】:ApacheCordova:"Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)"【发布时间】:2016-01-0408:48:27【问题描述】:我收到错误消息:“加载资源... 查看详情

加载资源失败:服务器响应状态为 404(未找到)

】加载资源失败:服务器响应状态为404(未找到)【英文标题】:Failedtoloadresource:theserverrespondedwithastatus404(notfound)【发布时间】:2015-12-0117:06:28【问题描述】:我在javascript和ajax上遵循lynda教程,并在主题“使用同步XHR请求”主... 查看详情

加载资源失败:服务器响应状态为 404(未找到)

】加载资源失败:服务器响应状态为404(未找到)【英文标题】:Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)【发布时间】:2014-07-1520:37:19【问题描述】:我在Eclipse中使用WorklightStudio。我创建了一个新工作区并创建了一个... 查看详情

加载资源失败:服务器响应状态为 404(未找到)显示在控制台上

】加载资源失败:服务器响应状态为404(未找到)显示在控制台上【英文标题】:Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)displayedonconsole【发布时间】:2021-10-2319:00:43【问题描述】:Image我的文件结构是index.html、script.js... 查看详情

Angular 5 - 加载资源失败:服务器响应状态为 404(未找到)

】Angular5-加载资源失败:服务器响应状态为404(未找到)【英文标题】:Angular5-Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)【发布时间】:2018-09-0703:44:17【问题描述】:我正在尝试从node_modules中的包中获取svg图像,我从我... 查看详情

加载资源失败:服务器使用 laravel 8 / ajax 响应状态为 404(未找到)

】加载资源失败:服务器使用laravel8/ajax响应状态为404(未找到)【英文标题】:Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)usinglaravel8/ajax【发布时间】:2021-09-1018:09:10【问题描述】:我正在尝试在HTMLbloc中显示图像,所以... 查看详情

加载资源失败:http://website.azurewebsites.net/signalr/hubs 服务器响应状态为 404(未找到)

】加载资源失败:http://website.azurewebsites.net/signalr/hubs服务器响应状态为404(未找到)【英文标题】:Failedtoloadresource:thehttp://website.azurewebsites.net/signalr/hubsserverrespondedwithastatusof404(NotFound)【发布时间】:2017-01-0421:19:02【问题描述】... 查看详情

在本地解析服务器上运行的解析仪表板错误出现:加载资源失败:服务器响应状态为 404(未找到)

】在本地解析服务器上运行的解析仪表板错误出现:加载资源失败:服务器响应状态为404(未找到)【英文标题】:parse-dashboardrunningonlocalparse-servererrorsoutinwith:Failedtoloadresource:theserverrespondedwithastatusof404(NotFound)【发布时间】:2021... 查看详情

无法加载资源 404(未找到) - 文件位置错误?

】无法加载资源404(未找到)-文件位置错误?【英文标题】:Failedtoloadresource404(NotFound)-filelocationerror?【发布时间】:2016-10-3101:44:33【问题描述】:我正在构建一个刚刚升级到NetCoreRC2的Angular2应用程序。在升级之前,我的网页可... 查看详情

为啥 Wordpress 无法加载资源?它表示服务器响应状态为 404(未找到)

】为啥Wordpress无法加载资源?它表示服务器响应状态为404(未找到)【英文标题】:whyWordpressfailedtoloadtheresource?Itsaidthattheserverrespondedwithastatusof404(notFound)为什么Wordpress无法加载资源?它表示服务器响应状态为404(未找到)【发布... 查看详情

带有 http-bind 的 strophe.js 无法加载资源 404 未找到

】带有http-bind的strophe.js无法加载资源404未找到【英文标题】:strophe.jswithhttp-bindfailedtoloadresource404notfound【发布时间】:2015-08-2414:45:20【问题描述】:我正在尝试使用strophe.js连接ejabberd服务器,但出现以下错误:POSThttp://localhost/ht... 查看详情

Ruby on rails 中的资源未找到错误

】Rubyonrails中的资源未找到错误【英文标题】:ResourcenotfounderrorsinRubyonrails【发布时间】:2018-01-2710:01:28【问题描述】:我对RoR很陌生,我知道ActiveRecord::RecordNotFound可以映射到http404错误。rubyonrails中是否还有其他资源不存在会引... 查看详情

Laravel 8 + nginx - 来自公共/未加载的 app.css 和 app.js 资源 - 未找到 404

】Laravel8+nginx-来自公共/未加载的app.css和app.js资源-未找到404【英文标题】:Laravel8+nginx-app.cssandapp.jsresourcesfrompublic/notloading-404notfound【发布时间】:2021-05-2523:26:13【问题描述】:这似乎是一个重复的问题,但它是不同的。相信我... 查看详情

Heroku jQuery JavaScript 库未加载 - 404 错误

】HerokujQueryJavaScript库未加载-404错误【英文标题】:HerokujQueryJavaScriptlibrarynotloading-404error【发布时间】:2017-05-2805:33:53【问题描述】:Heroku和我的生产环境未加载jQueryJavaScript库,导致以下“加载资源失败:服务器响应状态为404(... 查看详情

散景内联嵌入,“加载资源失败”

】散景内联嵌入,“加载资源失败”【英文标题】:BokehInlineEmbedding,\'Failedtoloadresource\'【发布时间】:2017-01-0313:31:03【问题描述】:我在嵌入Bokeh内联时遇到问题。特别是,从“链接”标签加载资源时存在问题(请参阅下面的html... 查看详情

Miniprofiler gem 生成大量 404 错误

...用程序中出现很多404错误:在chrome控制台中,标签网络:加载资源失败:服务器响应状态为404(未找到)http://loc 查看详情

rails 应用程序中的引导程序,404(未找到)

】rails应用程序中的引导程序,404(未找到)【英文标题】:boostrapinarailsapplication,404(NotFound)【发布时间】:2014-05-2118:22:15【问题描述】:我尝试按照***上的this程序集成引导程序(我的rails版本是3.2.17,这是一个区别),所以没... 查看详情