Twitter bootstrap MVC4样式。渲染&;脚本。提供澄清
我正在使用ASP.NET MVC 4和Bootstrap,我注意到我的项目与许多关于“使用Bootstrap构建站点”的文章和教程有点不同,它们不断提到使用Javascript和CSS的缩小文件(Bootstrap.min.CSS,Bootstrap.min.js)虽然文件在目录中,但我只有没有min的文件 我读过这些文件,但我不明白它的意思,也许有人可以澄清它们的用法,如果我需要在我的bundle配置中添加对它们的引用 我的代码如下所示: \u Layout.cshtml:Twitter bootstrap MVC4样式。渲染&;脚本。提供澄清,twitter-bootstrap,asp.net-mvc-4,scriptbundle,stylebundle,Twitter Bootstrap,Asp.net Mvc 4,Scriptbundle,Stylebundle,我正在使用ASP.NET MVC 4和Bootstrap,我注意到我的项目与许多关于“使用Bootstrap构建站点”的文章和教程有点不同,它们不断提到使用Javascript和CSS的缩小文件(Bootstrap.min.CSS,Bootstrap.min.js)虽然文件在目录中,但我只有没有min的文件 我读过这些文件,但我不明白它的意思,也许有人可以澄清它们的用法,如果我需要在我的bundle配置中添加对它们的引用 我的代码如下所示: \u Layout.cshtml: <head&
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="@Url.Action("Index", "Home")" class="navbar-brand">
<span class="glyphicon glyphicon-filter"></span> SelectorIT - OnLine
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
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 http://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"));
// Set EnableOptimizations to false for debugging. For more information,
// visit http://go.microsoft.com/fwlink/?LinkId=301862
BundleTable.EnableOptimizations = true;
}
}
我有两个问题:
min文件将删除所有不必要的字符,使文件变小。这将减少加载时间
如果您正在构建一个小型个人项目,性能可能没有高优先级。如果您正在为其他人或组织构建网站,我建议使用min版本。减少您的意思是加载时间?因此,如果我要使用较小的文件(.min.),我将回复“包含”将bootstrap.js改为bootstrap.min.js?就这么简单?我不需要留下“bootstrap.js”?只要替换它就行了?bootstrap.js和bootstrap.min.js包含完全相同的信息。区别在于bootstrap.js对我们人类更容易阅读。bootstrap.min.js对计算机更容易阅读。用bootstrap.js替换bootstrap.js是节省ap.min.js.#1:没什么区别,但在产品之间部署时,我们使用min.js.#2:好的捆绑包!是的,我个人更喜欢,因为我们不知道在我们的项目中引用了多少js文件。但是你可以添加捆绑包并使用它。谢谢,这是一个很好的问题,对我帮助很大