Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript imageSource.fromAsset getImageAsync错误_Nativescript - Fatal编程技术网

Nativescript imageSource.fromAsset getImageAsync错误

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

我正在尝试上载从设备库中拾取的base64编码图像

基本上,我选择图片并将其设置为
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