【问题标题】:Missing Icons in MVC 5 projectMVC 5 项目中缺少图标
【发布时间】:2018-12-09 17:44:13
【问题描述】:

我正在处理一个 MVC 5 项目。我已将SummerNote 集成到项目中。现在,您在上面的链接中看到的工具栏有一些图标。 当我运行我的项目时,它在本地运行良好,但是当我部署它时找不到图标。因此,由于我不完全了解整个事情是如何工作的,我通过更改 summernote-bs3.css 和 summernote.css 中的路径来修复部署,但随后本地版本当然坏了。

我为部署修复它的方式发生了变化:

@font-face {
font-family: 'Glyphicons Halflings';
src: url('~/Content/fonts/glyphicons-halflings-regular.eot');
src: url('~/Content/fonts/glyphicons-halflings-regular.eot?#iefix')     
format('embedded-opentype'), url('~/Content/fonts/glyphicons-     halflings-    
regular.woff') format('woff'), url('~/Content/fonts/glyphicons-halflings-
regular.ttf') format('truetype'), url  ('~/Content/fonts/glyphicons-
halflings-regular.svg#glyphicons_halflingsregular') format('svg');}

到:

@font-face {
font-family: 'Glyphicons Halflings';
src: url('../Content/plugins/fonts/glyphicons-halflings-regular.eot');
src: url('../Content/pluginsfonts/glyphicons-halflings-regular.eot?#iefix') 
format('embedded-opentype'), url('../Content/plugins/fonts/glyphicons-
halflings-regular.woff') format('woff'), 
url('../Content/plugins/fonts/glyphicons-halflings-regular.ttf') 
format('truetype'), url('~/Content/fonts/glyphicons-halflings-
regular.svg#glyphicons_halflingsregular') format('svg');}

请注意,我将 ~/Content/fonts/ 更改为 ../Content/fonts/。我也对 summernote.css 做了同样的事情。

原因是在我的部署中,我看到有人尝试下载:

https://mysite.azurewebsites.com/plugins/~/content/fonts/.....

但它找不到它,即使 ~ 表示 home,在这种情况下实际上与 ../ 相同。

所以我不太确定如何解决这个问题。这些路径是如何工作的或者它们是从哪里获取的?

感谢您的想法和帮助。

【问题讨论】:

    标签: css asp.net-mvc asp.net-mvc-5 summernote


    【解决方案1】:

    好的,经过数小时的试用,我弄清楚了如何将字体/样式的路径添加到网站的 URL 中。在 bundle.config 中:

    bundles.Add(new StyleBundle("~/plugins/summernoteStyles").Include(

    上面以粗体显示的基础被添加到您网站域的末尾。所以我得到了:

    https://mysite.azurewebsites.net/plugins/fonts/glyphicons-halflings-regular.woff

    为了修复它,我将 bundle.config 更改为如下所示:

    bundles.Add(new StyleBundle("~/Content/plugins/summernote/summernoteStyles").Include(

    也许有一天它会帮助别人。

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多