javascript - 如何在 Angular 2 应用程序中包含 jquery 库

标签 javascript angular angular2-forms

如何在 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/

相关文章:

Angular 5 - 动态地为特定元素添加样式

angular - GraphQL + Angular 2 服务

angular - 如何使用 Angular 检测浏览器?

angular - 在需要表达式的地方得到了插值 ({{}})

angular - 禁用 Angular 2+ html 模板中的绿色波浪线

javascript - 计算输入数量 onchange

javascript - 如何删除地址栏中的弹出窗口阻止程序

angular - 以 Angular 提交时显示表单验证错误消息

javascript - BrowserCouch,帮助基本示例

javascript复选框/取消选中同一div中的多个项目