【发布时间】:2018-04-30 04:29:00
【问题描述】:
我想在我的 Angular2 应用程序中使用 floatThead。 我已将 jquery 安装为全局库。
在 angular-cli.json 中
"scripts": ["../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/ngx-rating/ngx-rating.pure.amd.js",
"../node_modules/bootstrap-select/dist/js/bootstrap-select.min.js",
"../node_modules/floatthead/dist/jquery.floatThead.min.js"
],
在组件中,我同时导入了 jquery 和 floatThead,如下所示
import * as $ from 'jquery';
import * as floatThead from 'floatThead';
...
$('card-list-table').floatThead({top:110,
responsiveContainer: function($table){
return $table.closest(".table-responsive");
}
});
没有编译问题,但我收到此运行时错误并且插件不起作用
ERROR TypeError: __WEBPACK_IMPORTED_MODULE_5_jquery__(...).floatThead is not a function
at CustomerListComponent.webpackJsonp.../../../../../src/app/
看起来即使我已全局导入 jquery,但加载 jquery 插件时出现问题。
有人可以建议在这种情况下有什么问题吗?
【问题讨论】:
标签: angular webpack angular-cli