Sna*_*yes 31 c# asp.net-mvc asp.net-mvc-4 twitter-bootstrap
我遇到了一个问题,在我看来很奇怪.
我通过nuget包控制台安装了bootstrap.
之后,在BundleConfig.cs文件中,我添加了两个要bundles列出的项目:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.min.js"));
bundles.Add(new StyleBundle("~/Content/bootstrap").Include(
"~/Content/bootstrap.min.css",
"~/Content/bootstrap-theme.min.css"));
Run Code Online (Sandbox Code Playgroud)
当然,这些文件存在于本地.
该_Layout.cshtml文件包含
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/bootstrap")
</head>
<body>
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是当我看到一个视图(例如登录页面)时,我看到该bundle没有附加bootstrap部分.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Login</title>
<link href="/Content/Site.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.6.2.js"></script>
<!-- I expect bootstrap here but it is not displayed -->
</head>
<body>
...
<script src="/Scripts/jquery-1.9.1.js"></script>
<!-- I expect bootstrap here but it is not displayed -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Rad*_*ler 66
使用Bundle时,请不要附加 .min
bundles.Add(new StyleBundle("~/Content/bootstrap").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-theme.css"));
Run Code Online (Sandbox Code Playgroud)
基于调试设置,(主要是web.config)
debug="true" - 将使用非缩小版本. debug="false"- *.min.css将被搜索,如果没有找到,将缩小当前web.config设置:
<system.web>
<compilation debug="true"...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40429 次 |
| 最近记录: |