Angular TypeError:无法读取属性';拆分';空值(…;)
我收到TypeError:在ionic2 angular 2中使用cordova传输插件将图像上载到服务器时,无法读取null(…)错误的属性“split”。这是代码 用于保存图像路径的图像选择器代码:Angular TypeError:无法读取属性';拆分';空值(…;),angular,cordova-plugins,ionic2,Angular,Cordova Plugins,Ionic2,我收到TypeError:在ionic2 angular 2中使用cordova传输插件将图像上载到服务器时,无法读取null(…)错误的属性“split”。这是代码 用于保存图像路径的图像选择器代码: ImagePick() { let options = { destinationType : Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.PHOT
ImagePick() {
let options = {
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
};
Camera.getPicture(options).then((imageData) => {
this.Image = imageData;
console.log(this.Image);
}, (err) => {
// Handle error
});
}
文件传输选项
let options = {
fileKey: "avatar",
fileName: "image.jpg",
mimeType: "image/jpeg",
params: {
food: this.navParams.get("food"),
location_id: this.navParams.get("location"),
address: this.navParams.get("address"),
instructions: this.navParams.get("instructions"),
phone: this.myForm.controls.phone.value,
code: "b08d131e06",
outlets_attributes: 'outlet'
},
headers: {headers: this.user_service.Get_Header()}
};
console.log(this.Image);
使用cordova传输插件上传带有其他表单元素的图像
let fileTransfer = new Transfer();
if(this.Image!=null && this.Image!=""){
console.log(this.Image);
fileTransfer.upload(this.Image, URL, options).
then((data) => {
console.log(data);
}, (err) => {
console.log(err);
});
}
我做错了什么。我需要帮助。。。
谢谢 您可以粘贴完整的错误日志吗?TypeError:无法读取null(…)的属性“split”,仅获取此错误检查导致日志中此错误的文件和行。这是由于在option->params->header:{headers:this.user_service.Get_header()}中添加了头而发生的你知道如何在参数中添加标题和其他表单元素。你能粘贴完整的错误日志吗?TypeError:无法读取null(…)的属性“split”,只是获取此错误检查导致日志中此错误的文件和行。这是由于在选项->参数->标题中添加标题造成的:{headers:this.user_service.Get_Header()}您知道如何在params中添加Header和其他表单元素吗。。