【发布时间】:2019-10-20 14:03:42
【问题描述】:
我正在尝试使用 Ionic 4 编写一个简单的相机应用程序,这是我的代码 sn-p,用于捕获图像并将其显示在 Ionic 选项卡中。
export class UploadPage {
yourImage: SafeResourceUrl;
constructor(private sanitizer: DomSanitizer) { }
async captureImage() {
const capturedImage = await Plugins.Camera.getPhoto(
{
quality: 90,
allowEditing: true,
source: CameraSource.Camera,
resultType: CameraResultType.Uri
});
this.yourImage = this.sanitizer.bypassSecurityTrustResourceUrl(capturedImage && (capturedImage.dataUrl));
}
}
当我尝试运行代码时,它看起来可以捕获图像,但它没有显示在浏览器中。我看到了这个
在网络控制台中,我看到了这个
该图像也不会显示在 devapp 中。
奇怪的是,当我在 Android 手机上测试时,图像在磁盘上保存得很好,但它仍然没有显示在页面上。
【问题讨论】:
标签: angular ionic-framework ionic4 capacitor