问题
i installed jquery plugin in angular 2 project Link
npm i jquery-bootstrap-scrolling-tabs
and add in .angular-cli.json
"styles": [
"styles.css",
"../node_modules/jquery-bootstrap-scrolling-tabs/dist/jquery.scrolling-tabs.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/jquery-bootstrap-scrolling-tabs/dist/jquery.scrolling-tabs.js"
],
and i declare the veritable typings.d.ts
declare var scrollingTabs:any;
using in app.component.ts
ngAfterViewInit() {
$('.nav-tabs').scrollingTabs({
scrollToTabEdge: true
});
}
error: TypeError: __WEBPACK_IMPORTED_MODULE_1_jquery___default(...)(...).scrollingTabs is not a function
回答1:
you forgot to add the jquery variable
declare var $ : any
For more info on how to add jquery use this LINK with and without typings
回答2:
Import jquery in your component file.
declare let $ : any
来源:https://stackoverflow.com/questions/46031112/how-to-include-jquery-plugins-in-angular-2