如何在 Angular 2 应用程序中包含第三方 jQuery 库?
如何包含http://keith-wood.name/calendarspicker.html Angular 2 应用程序中的 jQuery 库?
最佳答案
1-除了通过 npm 安装它之外,请尝试将此行包含在 angular-cli.json 文件中的 apps->scripts 键中,如下例所示:
{
"apps": {
"scripts": [
"../node_modules/jquery/dist/jquery.min.js"
]
}
}
2-将此插件添加到 webpack.config.js 中的 webpack 插件中(在 module.exports 中):
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
3-然后将其导入到您需要使用它的组件中,例如:
从'jquery'导入*作为$;
关于javascript - 如何在 Angular 2 应用程序中包含 jquery 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51268266/