我是 ASP.NET MVC 4 的新手,我想在我的项目的一个页面中添加一个 jquery 控件。
这是我的 _layout.cshtml 文件的结尾部分:
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
1. @Script.Render("~/bundles/jquery") 行到底是什么?
在我希望添加控件的页面内:
@{
ViewBag.Title = "Test page";
}
@section scripts
{
@Scripts.Render("~/Scripts/jquery-1.8.2.js") // The control needs jquery.
@Scripts.Render("~/Scripts/icarousel.min.js") // The control in question.
@Styles.Render("~/Content/icarousel.css") // A css file needed by the control.
}
<script type="text/javascript">
$(document).ready(function () {
$('#icarousel').iCarousel();
});
</script>
(some html code here, including the #icarousel div ... )
当我运行该页面时,我收到错误:'$' is undefined。
这就像 jquery 没有加载或什么的......
2.我缺少什么来完成这项工作?