这是捆绑配置
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/datatable").Include(
"~/Scripts/DataTables/jquery.dataTables.js",
"~/Scripts/DataTables/dataTables.bootstrap.js"
));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"
));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/DataTables/css/dataTables.bootstrap.css",
"~/Content/site.css"
));
}
}
这是_layout
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/datatable")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
这是javascript
<script>
$(document).ready(function () {
$("#productTable").DataTable();
});
请帮帮我。我只是想弄清楚为什么我一直有这个错误。看起来这是一个引用Datatable libs的问题。 提前谢谢
答案 0 :(得分:0)
请在您的视图中使用@section脚本。
@section scripts
{
<script>
$(document).ready(function () {
$("#productTable").DataTable();
});
</script>
}