如何在 Angular 8+ 中使用 Panzoom javascript?

dot*_*pro 2 javascript typescript angular-cli angular panzoom

我无法在 Angular 中使用Panzoom Javascript 库。我得到

ERROR
Error: panzoom is not defined
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止所做的事情的堆栈闪电战。这是它应该如何工作的工作演示

任何人都可以帮我排除故障吗?谢谢

我按照这个提到的所有步骤

dot*_*pro 6

似乎 Panzoom 确实有打字稿定义Github 问题

这是一个有效的stackblitz

import { Component, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
import panzoom from "panzoom";

@Component({
  selector: 'hello',
  template: `<img id="scene" #scene src="https://www.probytes.net/wp-content/uploads/2018/01/5-1.png">`,
  styles: []
})
export class HelloComponent implements AfterViewInit {
  @ViewChild('scene', { static: false }) scene: ElementRef;

  ngAfterViewInit() {
    // panzoom(document.querySelector('#scene'));
    panzoom(this.scene.nativeElement);
  }
}
Run Code Online (Sandbox Code Playgroud)