ionic-framework - 不允许在 ionic 中加载本地资源
问题描述
我正在尝试在离子中使用相机,它正在单击照片但不显示照片。
getCamera() {
this.camera.getPicture().then((res)=>{
this.imageURL = res;
console.log(this.imageURL);
}).catch(e=>{
console.log(e);
})
}
控制台向我展示
不允许加载本地资源我正在尝试在我的集合组件中使用 imageURL,例如
<img src={{imageURL}} alt="" height="200" width="200" />
解决方案
Try This
const options: CameraOptions = {
quality: 90,
targetWidth: 350,
targetHeight: 350,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.CAMERA, // this.camera.PictureSourceType.SAVEDPHOTOALBUM
correctOrientation: true,
allowEdit: true
};
this.camera.getPicture(options).then((imageData) => {
if (imageData) {
this.imageURL = 'data:image/jpeg;base64,' + imageData;
}
}, (err) => {
});
推荐阅读
- laravel - 如何在 Laravel 5 中使用 Codeception 在单元测试中模拟身份验证用户?
- selenium - 无法单击“使用电子邮件注册”按钮
- r - 将函数应用于 R 中许多列的子集
- javascript - 在数组中生成唯一数字
- ms-access - ms 访问表单以插入记录组
- jmeter - 在 CircleCI 中自动化 jmx 文件
- php - 在 Laravel 5.7 上确定每个用户级别/角色的布局
- python-3.x - 带有 AES CBC 的 AWS KMS python3.6 和 boto3 示例
- go - 使用 Golang 导出导入
- swift - UICollectionViewCell 委托不会触发