我的 _Layout.cshtml 像这样
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - E-Reader Statistics</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@* @Scripts.Render("~/bundles/jquery")*@
<link href="~/jqGrid/css/ui.jqgrid.css" rel="stylesheet" />
<script src="~/jqGrid/js/i18n/grid.locale-en.js"></script>
<script src="~/jqGrid/js/jquery-1.9.0.min.js"></script>
<script src="~/jqGrid/js/jquery.jqGrid.min.js"></script>
<script src="~/jqGrid/js/jquery.jqGrid.src.js"></script>
</head>
在 Index.chtml 中
@model List<LSStatisticalReport.ViewModels.GSViewModel>
@{
ViewBag.Title = "Index";
}
@*<h2>General Statistics</h2>*@
<script type="text/javascript">
// var jq = $.noConflict();
$(document).ready(function () {
var genStatGrid = $('#list');
genStatGrid.jqGrid({
caption: "General Statistics",
url: '/Statistics/GetRecords/',
datatype: "json",
contentType: "application/json; charset-utf-8",
mtype: 'POST',
colNames: ['Student', 'Teacher', 'Date'],
colModel: [
{ name: 'studentDesignation' },
{ name: 'teacherDesignation' },
{ name: 'dateLength' },
],
rowNum: 5
});
});
</script>
但是当我运行项目时,我在控制台中遇到错误:
“未捕获的类型错误:对象 [对象对象] 没有方法 'jqGrid'”