使用通常的语法
<link rel="stylesheet" href="~/assets/css/bootstrap.min.css">
<link rel="stylesheet" id="css-main" href="~/assets/css/site.css">
<link rel="stylesheet" id="css-main" href="~/assets/css/bluetheme.css">
一切都按预期运作。 为了清理一下,我想使用Style.Render
@Styles.Render("~/assets/css")
我认为包含该文件夹中的所有css文件。
但样式不适用于页面。我做错了什么?
更新:我的BundleConfig中有两个拼写错误,但它们现在已修复,样式仍无法正常工作
这是我的捆绑配置
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
bundles.Add(new StyleBundle("~/assets/css").Include(
"~/assets/bootstrap.min.css",
"~/assets/site.css",
"~/assets/bluetheme.css"
));
}
,这是我的布局视图的头部分
@Styles.Render("~/assets/css")