【问题标题】:Using waypoints.js in Angular 4 application在 Angular 4 应用程序中使用 waypoints.js
【发布时间】:2019-04-10 20:47:43
【问题描述】:

嘿,我试图在我的 Angular 应用程序中使用 Waypoints.js。我似乎无法让它工作

angular-cli.js

"scripts": [
    "../node_modules/waypoints/lib/noframework.waypoints.min.js"
  ]

app.component.ts

import { Component,  OnInit } from '@angular/core';
    declare var Waypoint: any;

export class OurTechnologyComponent implements OnInit {

  constructor() {}

  ngOnInit() {

    //waypoints
    const grinner = new Waypoint({
      element: document.querySelector('.tech-section'),
      handler: function () {
        alert('hello');
      }
    });

  }

我收到一个错误..

任何帮助将不胜感激

谢谢!

编辑

我已经安装了 Waypoints Types 并导入了它import * as Waypoint from 'waypoints';

收到错误[ts] file pathtofolder/@types/waypoints/index.d.ts is not a module

【问题讨论】:

  • 你能解决这个问题吗?

标签: javascript angular typescript


【解决方案1】:

在 app.component.ts 中替换

declare var Waypoint: any;

declare const Waypoint: any;

会成功的。

P.S:我目前使用的是 Angular 7,这个解决方案对我有用。

【讨论】:

    【解决方案2】:

    安装Waypoints types为航点安装类型。

    import * as Waypoint from 'waypoints'.
    

    希望对你有帮助。

    【讨论】:

    • 我收到此错误[ts] file pathtofolder/@types/waypoints/index.d.ts is not a module
    • @A61NN5 航点接口库需要更新。现在,您可以在 index.d.ts 中为每个类声明导出。使用导出包名 = 包名。这应该工作。
    • 这是后续问题,尝试实施您的解决方案但没有。请看stackoverflow.com/questions/53854977/…
    猜你喜欢
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-07-15
    • 2018-01-12
    • 1970-01-01
    相关资源
    最近更新 更多