您可能已经包含该~/bundles/jquery
捆绑包两次。签出你的~/Views/Shared/_Layout.cshtml
文件。最后你可能有以下内容:
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
所以 jQuery 包已经包含在您的页面中。您不应该再次将它包含在您的视图中。您只需要~/bundles/jqueryui
捆绑:
@Scripts.Render("~/bundles/jqueryui")
<script type="text/javascript">
$(function () {
$("#sections").tabs();
//here i am getting error that Object[object object] has not method tabs
});
</script>
<div id="sections">
<ul>
<li><a href="#section-1">section-1 </a></li>
<li><a href="#section-2">section-2 </a></li>
</ul>
<div id="section-1">
section-1 content............
</div>
<div id="section-2">
section-2 content............
</div>
</div>
更新:
以下是您的视图结构的完整示例:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Foo</title>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
</head>
<body>
<div id="sections">
<ul>
<li><a href="#section-1">section-1 </a></li>
<li><a href="#section-2">section-2 </a></li>
</ul>
<div id="section-1">
section-1 content............
</div>
<div id="section-2">
section-2 content............
</div>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
<script type="text/javascript">
$("#sections").tabs();
</script>
</body>
</html>