我希望使用cropper.js (https://github.com/fengyuanchen/cropperjs) 创建一个 Angular2 裁剪器,并且要使用 angular-cli。
我的指令代码如下:
import {Directive, ElementRef, Input, OnInit} from '@angular/core';
import Cropper from 'cropperjs';
@Directive({
selector: '[ng2-cropper]'
})
export class Ng2CropperJsDirective implements OnInit {
@Input('options') options: any = {};
private cropper;
constructor(private _element: ElementRef) { }
ngOnInit(): void {
console.log(Cropper);
this.cropper = new Cropper(this._element.nativeElement, this.options);
}
}
ng serve
出错了: Cannot find module 'cropperjs'
但是cropperjs在node_modules
中,而且我的angular-cli.json
已经更新为:
"scripts": [
"../node_modules/cropperjs/dist/cropper.js"
],
我不知道如何解决这个问题。