【MVC】Scripts.Render的用法
2021-06-22 09:06
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:accordion code stat 用法 auto virt height ble span
一、配置BundleConfig.cs文件
1、首先要在App_Start 里面BundleConfig.cs 文件里面 添加要包含的css文件
2、BundleConfig就是一个微软新加的 一个打包的配置类
3、BundleConfig用来Add 各种Bundle
4、BundleConfig配置信息如下:
public class BundleConfig {
public static void RegisterBundles(BundleCollection bundles) {
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new StyleBundle("~/Content1/css").Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content1/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
二、使用Scripts.Render、Styles.Render引用BundleConfig中的配置
1、在视图文件中使用Scripts.Render()输出脚本包,Styles.Render()输出样式包
2、Script文件引用:@Scripts.Render(virtualPath[,virtualPath1][,virtualPath2][,...])
3、CSS文件引用: @Styles.Render(virtualPath[,virtualPath1][,virtualPath2][,...])
4、实例
DOCTYPE html>
meta charset="utf-8" />
meta name="viewport" content="width=device-width" />
@ViewBag.Titletitle> @Styles.Render("~/Content1/css")
head>
@RenderBody()
@Scripts.Render("~/bundles/jqueryui")
body>
html>
【MVC】Scripts.Render的用法
标签:accordion code stat 用法 auto virt height ble span
原文地址:http://www.cnblogs.com/iwsx/p/7171406.html