Nativescript imageSource.fromAsset getImageAsync错误
我正在尝试上载从设备库中拾取的base64编码图像 基本上,我选择图片并将其设置为Nativescript imageSource.fromAsset getImageAsync错误,nativescript,Nativescript,我正在尝试上载从设备库中拾取的base64编码图像 基本上,我选择图片并将其设置为ImageView的source。 稍后我上传ImageView的src是什么 我正在使用nativescript imagepicker选择图像: let context = imagePicker.create({ mode : "single" }); context.authorize() .then(()=>{ return context.prese
ImageView
的source
。
稍后我上传ImageView
的src
是什么
我正在使用nativescript imagepicker
选择图像:
let context = imagePicker.create({
mode : "single"
});
context.authorize()
.then(()=>{ return context.present();})
.then((selection)=>{
selection.forEach((selected)=>{
selected.getImage().then((value :ImageSource)=>{
imageView.src = value; //here I set the image as source
})
})
});
之后,在上载方法中,我尝试执行以下操作:
fromAsset
方法是Nativescript的ImageSource
模块的一部分
fromAsset(imageView.src).then(
(res) => {
imageSource = res;
photo.base64 = imageSource.toBase64String('jpg');
..
}).catch((error)=>{
console.log(error); // here I get TypeError.asset.getImageAsync is not a function
})
当我对直接从相机拍摄的图像使用上述方法时,一切都很顺利,但是如果从gallery中选择图像,我会得到以下错误:TypeError.asset.getImageAsync不是一个函数
我做错了什么?我使用了此链接中的代码,工作正常!我希望它能工作我在这个链接中使用了代码,工作得非常完美!我希望它能起作用更新您的tns核心模块和NativeScript客户端,在使用Gallery中的临时图像时,您可能希望显式保存它们,然后从中创建一个imageSource更新您的tns核心模块和NativeScript客户端,使用Gallery中的临时图像时,您可能希望显式保存它们,然后从中创建imageSource