我正在尝试在Angular 5中导入这个DataTable Jquery插件(我在加载JQuery和Bootstrap之后包含了两个脚本)
“https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js” “https://cdn.datatables.net/1.10.11/js/dataTables.bootstrap.min.js”
但我一直收到这个错误:
ERROR TypeError:__ WWEPACK_IMPORTED_MODULE_1_jquery_dist_jquery ___ default(...)(...)。DataTable不是函数
我已将依赖项添加到angular-cli.json
:
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../3rdParty/data-tables/js/jquery.dataTables.min.js",
"../3rdParty/data-tables/js/dataTables.bootstrap.min.js"
],
并在我的component.ts
文件中导入jquery和插件
import $ from 'jquery/dist/jquery';
import * as dt1 from '../../../../../3rdParty/jquery.dataTables.min';
import * as dt2 from '../../../../../3rdParty/dataTables.bootstrap.min';