【发布时间】:2017-01-03 15:36:00
【问题描述】:
我想裁剪 3 张图片,然后上传使用 Angular 2 裁剪的图片。 我集成了 Angular 2 Image Cropper“ng2-img-cropper”,但我没有让它工作。
当我运行应用程序并转到实现裁剪器的页面时,我只看到一个小图像方块,当我单击或拖动它时没有任何反应,并且控制台中没有错误。 Figure : Empty image square
我正在使用“ng2-img-cropper@4.6”。
这就是我进行实施的方式。 我参考了这个 Github 链接https://github.com/cstefanache/angular2-img-cropper 我将它添加到 HTML 中
<div>
<img-cropper [image]="data" [settings]="cropperSettings"></img-cropper><br>
<img [src]="data.image" [width]="cropperSettings.croppedWidth" [height]="cropperSettings.croppedHeight">
</div>
然后这个进入类
import {ImageCropperComponent, CropperSettings} from 'ng2-img-cropper';
data: any; cropperSettings: CropperSettings;
constructor() {
this.cropperSettings = new CropperSettings();
this.cropperSettings.width = 100;
this.cropperSettings.height = 100;
this.cropperSettings.croppedWidth =100;
this.cropperSettings.croppedHeight = 100;
this.cropperSettings.canvasWidth = 400;
this.cropperSettings.canvasHeight = 300;
this.data = {};
}
谢谢。
链接到问题Issue
【问题讨论】: