字体真棒无法在MVC5中运行bundleconfig
如果我直接参考font-awesome.css
_layouts页面。它会工作
<link href="~/Content/font-awesome-4.0.3/css/font-awesome.css" rel="stylesheet" />
但是我用过BundleConfig.cs
。图标未显示。
bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/font-awesome-4.0.3/css/font-awesome.css",
"~/Content/bootstrap.css",
"~/Content/body.css",
"~/Content/site.css",
"~/Content/form.css"
));
而且我还观察到浏览器控制台对字体目录有错误。 Failed to load resource: the server responded with a
status of 404 (Not Found) http://localhost:51130/fonts/fontawesome-
webfont.woff?v=4.0.3
可能是什么问题呢?
回答:
CssRewriteUrlTransform
捆绑时尝试使用:
bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css",
"~/Content/body.css",
"~/Content/site.css",
"~/Content/form.css"
).Include("~/Content/font-awesome-4.0.3/css/font-awesome.css", new CssRewriteUrlTransform());
这会将资产的所有url从css文件内更改为绝对url,因此绑定不会弄乱相对路径。
以上是 字体真棒无法在MVC5中运行bundleconfig 的全部内容, 来源链接: utcz.com/qa/409969.html