[英]Bundling in MVC4
In my MVC application, Initially I called all the scripts and styles in Each page. 在我的MVC应用程序中,最初,我在“每个页面”中调用了所有脚本和样式。 After seeing the Bundling concept.
看到捆绑概念之后。 I referred the scritps and styles in the Bundle.config page.
我在Bundle.config页面中提到了脚本和样式。 Here the scripts are not referred in my page.
这里的脚本在我的页面中没有引用。 I dont use a Layout page in my application.
我在应用程序中不使用“布局”页面。
Bundle.config Bundle.config
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{1.7.1}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{1.8.20}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryuc").Include(
"~/Scripts/jquery.dcmegamenu.1.3.3.js",
"~/Scripts/jquery.hoverIntent.minified.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryuh").Include(
"~/Scripts/html5.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryumin").Include(
"~/Scripts/jquery.uniform.min.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryea").Include(
"~/Scripts/jquery.easing.1.3.js",
"~/Scripts/jquery.hoverIntent.minified.js"));
bundles.Add(new StyleBundle("~/CSS/css").Include(
"~/CSS/AdminLayStyle.css",
"~/CSS/tab.css",
"~/CSS/login.css",
"~/CSS/login-box.css",
"~/CSS/base.css",
"~/CSS/style_file.css",
"~/CSS/menustyle.css"));
bundles.Add(new StyleBundle("~/CSS/Content/themes/base/css").Include("~/CSS/Content/themes/base/jquery-ui.css",
"~/CSS/Content/themes/base/jquery.ui.all.css",
"~/CSS/Content/themes/base/jquery.ui.base.css",
"~/CSS/Content/themes/base/jquery.ui.dialog.css",
"~/CSS/Content/themes/base/jquery-ui.css",
"~/CSS/Content/themes/base/jquery.ui.theme.css"));
and in View Index.cshtml 并在View Index.cshtml中
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryuc")
@Styles.Render("~/Content/css")
Is the reference to styles from Bundle.config is correct ?? 从Bundle.config中引用样式是否正确?
Thanks in advance. 提前致谢。
EDIT : 编辑:
Is it any rule that all styles should be referred only from Content folder ?? 是否所有规则都只能从Content文件夹引用?
Javascripts seem fine. Javascript看起来不错。 The CSS is wrong.
CSS错误。 There isn't any
~/Content/css
bundle defined. 没有定义任何
~/Content/css
包。 You probably meant: 您可能的意思是:
@Styles.Render("~/CSS/css")
Also you probably want to include the jQuery UI styles as well: 另外,您可能还希望包括jQuery UI样式:
@Styles.Render("~/CSS/Content/themes/base/css")
I got it. 我知道了。 The relative path to refer the styles and Images must be from Content folder.
引用样式和图像的相对路径必须来自Content文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.