首页 > 解决方案 > 如何在 Angular 7 中包含 boomerangjs 脚本文件?

问题描述

我正在尝试在我的 Angular 代码中实现 boomerangjs。但这对我不起作用。我需要你的帮助来解决它。下面是我使用它的方式。所以首先我使用 npm 安装了 boomerangjs,现在它可以在我的 node_modules 中使用。我的第一页是dashboard.component.ts,所以我在这个组件中添加了下面的代码。

    import {BOOMR} from 'node_modules/boomerangjs';

    export class DashboardComponent implements OnInit {
      ngOnInit() {         
         BOOMR.init({
          beacon_url: "/beacon"
        });   
        }
    }

但是我收到TypeError: Cannot read property 'init' of undefined错误。请帮助我如何在我的角度代码中使用“boomerangjs”。

编辑 1 - 我可以在列出导入的页面顶部看到 3 个点 ...。当我将鼠标悬停在以下消息的点上时:

Could not find a declaration file for module 'node_modules/boomerangjs'. 'd:/code/node_modules/boomerangjs/boomerang.js' implicitly has an 'any' type.
  Try `npm install @types/boomerangjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'boomerangjs';`

谢谢

标签: angular

解决方案


推荐阅读