我正在尝试在 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: __WEBPACK_IMPORTED_MODULE_1_jquery_dist_jquery___default(...)(...).DataTable is not a function
我已将依赖项添加到 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';
最佳答案
你见过this吗? ? 适用于 Angular 的 DataTables,适用于 v5.0.0
关于javascript - 将第 3 方 JS 文件导入 Angular 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47928106/