【问题标题】:How to add third-party scripts in Angular 6 custom elements如何在 Angular 6 自定义元素中添加第三方脚本
【发布时间】:2018-12-08 12:46:54
【问题描述】:

对于 Angular 6 中的自定义元素,如何添加 popper.js 和 jquery 等脚本,因为它们在添加到“angular.json”文件时不起作用?在 css 组件中导入 bootstrap 效果很好。

【问题讨论】:

  • 您是否尝试添加它们?
  • 或者可以将它们作为依赖项放在 index.html 中,带有 scripg 标签
  • 我将它们添加到 index.html 中。它只工作/响应一次,然后不再响应。

标签: angular6 custom-element


【解决方案1】:

1) 用法

npm i -g popper

2) 在 'angular.json' 内的 'build' 下添加路径

"scripts": [
             "node_modules/popper/popper.js"
           ]

请验证 node_modules 中的文件。

【讨论】:

  • 这只适用于我不在 Angular 6 中创建自定义元素的情况。
猜你喜欢
  • 2019-12-22
  • 1970-01-01
  • 2022-10-13
  • 2019-02-09
  • 2021-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多