【发布时间】:2020-09-19 10:48:21
【问题描述】:
我正在尝试使用名为 dataTables.js 的插件运行或启动脚本。我已经设法使用ES6 import 语句和jquery 依赖项导入库。当我尝试运行或启动插件时,我收到如下所示的错误
jQuery.Deferred exception: (0 , _jquery.default)(...).DataTable is not a function TypeError: (0 , _jquery.default)(...).DataTable is not a function
at HTMLDocument.eval (https://juwto.csb.app/src/index.js:13:37)
at j (https://juwto.csb.app/src/jquery.js:1977:29)
at k (https://juwto.csb.app/src/jquery.js:1983:19)
沙盒链接 - https://codesandbox.io/s/gracious-chaplygin-juwto?file=/index.html
即使我设法正确导入库,我似乎也找不到合适的解决方案或答案
import $ from "./jquery";
import _dt from "./datatables";
$(document).ready(function() {
$("#table").DataTable({
paging: false,
bFilter: false,
bInfo: false
});
});
【问题讨论】:
-
您的表 ID 是
table_id,而不是table。将此$("#table").DataTable({更改为$("#table_id").DataTable({,如果问题仍然存在,请参阅:stackoverflow.com/questions/31227844/… -
您只想在
index.js中导入jquery和datatables?
标签: javascript ecmascript-6 datatables