我遇到一个错误,无法读取离子文件插件中未定义的属性“ split”

时间:2019-04-09 11:12:12

标签: typescript ionic-framework

我正在使用此代码制作base64图像,但出现错误:

const options: CameraOptions = {
quality: 100,
allowEdit: true,
sourceType: source,
saveToPhotoAlbum: true,
correctOrientation: true,
encodingType: this.camera.EncodingType.JPEG,
destinationType: this.camera.DestinationType.FILE_URI
}

this.camera.getPicture(options).then((imageData) => {
    //needs to import file plugin
    //split the file and the path from FILE_URI result
    let filename = imageData.substring(imageData.lastIndexOf('/')+1);
    let path =  imageData.substring(0,imageData.lastIndexOf('/')+1);
         //then use the method reasDataURL  btw. var_picture is ur image variable
         this.file.readAsDataURL(path, filename).then(res=> var_picture = res  );
})



ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of undefined

所以也许有人知道这里真正的问题是什么?非常感谢。

0 个答案:

没有答案