visual studio插件中的jquery datatable不工作
嘿,我正试图在visual studio 2019中为我的代码创建一个jquery数据表,但数据表不会显示我已成功安装了“安装包引导盒”和“安装包jquery.DataTables”,但当我运行代码时,数据表不会显示。我在网上到处找都找不到答案。任何帮助都将不胜感激 编辑:当我右键单击项目“Inspect”时,会出现以下错误:visual studio插件中的jquery datatable不工作,jquery,visual-studio,datatables,Jquery,Visual Studio,Datatables,嘿,我正试图在visual studio 2019中为我的代码创建一个jquery数据表,但数据表不会显示我已成功安装了“安装包引导盒”和“安装包jquery.DataTables”,但当我运行代码时,数据表不会显示。我在网上到处找都找不到答案。任何帮助都将不胜感激 编辑:当我右键单击项目“Inspect”时,会出现以下错误: jquery.dataTables.js:1197 Uncaught TypeError: Cannot read property 'mData' of undefin
jquery.dataTables.js:1197 Uncaught TypeError: Cannot read property 'mData' of undefined
at HTMLTableCellElement.<anonymous> (jquery.dataTables.js:1197)
at Function.each (jquery-3.4.1.js:367)
at jQuery.fn.init.each (jquery-3.4.1.js:202)
at HTMLTableElement.<anonymous> (jquery.dataTables.js:1194)
at Function.each (jquery-3.4.1.js:367)
at jQuery.fn.init.each (jquery-3.4.1.js:202)
at jQuery.fn.init.DataTable [as dataTable] (jquery.dataTables.js:869)
at jQuery.fn.init.$.fn.DataTable (jquery.dataTables.js:15172)
at Index:153
Index.html
@model IEnumerable<AuditoriskaMVC1.Models.Movie>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table" id="moviesTable">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.DownloadURL)
</th>
<th>
@Html.DisplayNameFor(model => model.ImagedURL)
</th>
<th>
@Html.DisplayNameFor(model => model.Rating)
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
<a href="@item.DownloadURL">Download Here!</a>
</td>
<td>
<img style="max-width:200px" src="@item.ImagedURL" />
</td>
<td>
@Html.DisplayFor(modelItem => item.Rating)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
</tbody>
</table>
@section scripts{
<script>
$("#moviesTable").DataTable();
</script>
}
@model IEnumerable
@DisplayFor(modelItem=>item.Rating)
@ActionLink(“编辑”,“编辑”,新的{id=item.id})|
@ActionLink(“详细信息”,“详细信息”,新的{id=item.id})|
@ActionLink(“删除”,“删除”,新的{id=item.id})
}
@节脚本{
$(“#moviesTable”).DataTable();
}
好吧,我想出来了,但万一有人有这个问题,我就把这篇文章留下
解决方案是,桌面和桌面需要具有相同数量的
在这种情况下,表头少了1个,因此即使您在Visual Studio中由于某种原因没有收到任何错误,后台也有一个,只有右键单击并检查页面时,您才能看到它。如果你的脑袋或身体里的东西少了,那就加一个空的吧。什么,对不起?
@model IEnumerable<AuditoriskaMVC1.Models.Movie>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table" id="moviesTable">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.DownloadURL)
</th>
<th>
@Html.DisplayNameFor(model => model.ImagedURL)
</th>
<th>
@Html.DisplayNameFor(model => model.Rating)
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
<a href="@item.DownloadURL">Download Here!</a>
</td>
<td>
<img style="max-width:200px" src="@item.ImagedURL" />
</td>
<td>
@Html.DisplayFor(modelItem => item.Rating)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
</tbody>
</table>
@section scripts{
<script>
$("#moviesTable").DataTable();
</script>
}