我已经通过nuget安装了jquery ui并按照How to add jQueryUI library in MVC 5 project中的描述设置了捆绑。从默认的MVC 5项目开始,我在 RegisterBundles
中添加了以下内容 bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/accordion.css",
"~/Content/themes/base/all.css",
"~/Content/themes/base/autocomplete.css",
"~/Content/themes/base/base.css",
"~/Content/themes/base/button.css",
"~/Content/themes/base/core.css",
"~/Content/themes/base/datepicker.css",
"~/Content/themes/base/dialog.css",
"~/Content/themes/base/draggable.css",
"~/Content/themes/base/menu.css",
"~/Content/themes/base/progressbar.css",
"~/Content/themes/base/resizable.css",
"~/Content/themes/base/selectable.css",
"~/Content/themes/base/selectmenu.css",
"~/Content/themes/base/slider.css",
"~/Content/themes/base/sortable.css",
"~/Content/themes/base/spinner.css",
"~/Content/themes/base/tabs.css",
"~/Content/themes/base/theme.css",
"~/Content/themes/base/tooltip.css"));
这是我的Index.cshtml
@{
ViewBag.Title = "Home Page";
}
@Scripts.Render("~/bundles/jqueryui")
@Styles.Render("~/Content/themes/base/css")
<script type="text/javascript">
$(document).ready(function () {
$("#accordion").accordion({ header: "h3", collapsible: true, active: false });
});
</script>
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>
A
</p>
</div>
<h3>Section 1</h3>
<div>
<p>
A
</p>
</div>
<h3>Section 1</h3>
<div>
<p>
A
</p>
</div>
</div>
然而,当我跑步时,没有明显的区别。
编辑:仅供参考这是My layout running in Fiddler
答案 0 :(得分:1)
除了jquery UI之外,还需要添加jquery。
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Styles.Render("~/Content/themes/base/css")