Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何使用机车滚动轴承_Angular_Locomotive Scroll - Fatal编程技术网

Angular 如何使用机车滚动轴承

Angular 如何使用机车滚动轴承,angular,locomotive-scroll,Angular,Locomotive Scroll,有没有一种方法可以使用机车滚动的角度。我在谷歌上找不到这方面的任何信息。有人用过机车卷轴吗 我试图在我的主页中导入它。component.ts: import {Component, HostListener, OnInit} from '@angular/core'; import {AppComponent} from '../app.component'; import LocomotiveScroll from 'locomotive-scroll'; @Component({

有没有一种方法可以使用机车滚动的角度。我在谷歌上找不到这方面的任何信息。有人用过机车卷轴吗

我试图在我的主页中导入它。component.ts:

import {Component, HostListener, OnInit} from '@angular/core';
import {AppComponent} from '../app.component';
import LocomotiveScroll from 'locomotive-scroll';


@Component({
  selector: 'app-homepage',
  templateUrl: './homepage.component.html',
  styleUrls: ['./homepage.component.css']
})
export class HomepageComponent implements OnInit {
  scroll;

  constructor() {

  }

  @HostListener('window:load')
  initLocomotiveScroll() {
    this.scroll = new LocomotiveScroll({
      el: document.querySelector('[data-scroll-container]'),
      smooth: true,
    });
  }

}
homepage.componenet.html:

<div data-scroll-container style="height: 100%; overflow: scroll">
  <div data-scroll-section>
    <h1 data-scroll>Hey</h1>
    <p data-scroll>Your problem is the strict attribute.

FIX tsconfig.json

Set the strict attribute in the tsconfing.json file to false

 "strict": false

您的问题在于严格属性

修复tsconfig.json

将tsconfig.json文件中的strict属性设置为false


这对我有用

机车卷轴必须知道您的内容高度才能正常工作。要解决此问题,请在呈现或更改内容时调用机车滚动的更新方法。这可以通过使用机车滚动的.update()函数来完成


如本教程所述,您可以使用resize observer自动执行更新函数调用:

什么是机车滚动?这是一个创建滚动效果的库:这是一个简单的js库。为什么你不能直接导入并使用它呢?如果你尝试了一些不起作用的东西,请告诉我们你做了什么我在我的主页中导入了它。component.t也许可以创建一个小示例(stackblitz或其他)来重现这个问题这对我不起作用