更新时间:2023-09-30 09:56:16
您应该能够导入 Vinilla-tilt 并使用传递给构造函数的元素引用.
You should be able to import Vinilla-tilt and use the element reference passed into the constructor.
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
const VanillaTilt = require('vanilla-tilt');
@Directive({
selector: '[data-tilt]'
})
export class ParallaxDirective {
constructor(private el: ElementRef) {
VanillaTilt.init(el.nativeElement, {
max: 25,
speed: 400
});
}
}