1
 window.onload = function() {
  svgPanZoom('#demo-tiger', {
    zoomEnabled: true,
    controlIconsEnabled: true
  });
};

上面的代码不适用于 Angular ??

4

1 回答 1

4

我使用了 svg-pan-zoom 3.5.x 版本,下面的代码片段可以帮助您导入库。

    // Psuedo angular TS code

    import * as SvgPanZoom from 'svg-pan-zoom';

    @Component({
      selector: 'app-svg-container',
      templateUrl: './svg-container.component.html',
      styleUrls: ['./svg-container.component.scss']
    })
    export class SvgContainerComponent implements OnInit, AfterViewInit {

      constructor() { }

      ngOnInit() {  }

      ngAfterViewInit() {
        // initializing the function
        let svgPanZoom: SvgPanZoom.Instance = SvgPanZoom('#wolrd-map-svg', this.options);
     /* see typing definiton for more APIs. */

      }

        ... More Codes...

    }
于 2018-01-24T14:43:10.120 回答