代码之家  ›  专栏  ›  技术社区  ›  GeorgeK

属性“GimTimes”不存在于“IMASSET”类型

  •  0
  • GeorgeK  · 技术社区  · 6 年前

    我使用NATScript脚本Ipple Posiver插件,并通过使用下面的代码来获得特定的错误(“属性”GeimTimes”不存在于“IMAGASSET”类型):

    this.context.authorize()
      .then(() => {
        return this.context.present();
      })
      .then((selection) => {
        selection.forEach((selected) => {
          selected.getImage().then((imagesource) => {
            const folder = fileSystem.knownFolders.documents();
            const path = fileSystem.path.join(folder.path, milliseconds + ".png");
            const saved = imagesource.saveToFile(path , "png");
            this.newImage = path;
          });
        });
      });
    

    环顾四周,我发现其他人报告了这个问题,但找不到解决办法。YouTube视频中关于该插件的提示是,“我使用了NS2.5,因此它在NS3+_中可能有所不同?” video 我希望有帮助。

    similar question 一段时间前已经贴到这里了,没有回复,但是没有回复。提前谢谢

    2 回复  |  直到 6 年前
        1
  •  2
  •   Nick Iliev    6 年前

    根据API参考 ImageAsset 没有 getImage 方法。有一种方法 getImageAsync 你可以用的。

    插件 nativescript-imagepicker 最近还引入了一些破坏性的更改,因此您可能希望将代码与新的代码基对齐。

    从5.x.x迁移到6.x.x,版本为6.x.x NistScript脚本UI ListVIEW插件被删除,对于iOS 使用Qbimagepicker可可豆。现在插件支持一些新的 功能,修复了一些错误,并在ios中具有更自然的外观。你 应该删除任何依赖于NATEVScript PRO UI, NATScript脚本UI ListVIEW,以防您在应用程序中添加它们 特别是这个插件。还有选项fileuri,donetext, 取消文本、Apple MistEXT、NeWestEnter和方法CPLANCEL() done()不再适用。图像选择器现在返回 基本的{n}imageasset类(而不是像以前那样自定义资产)。如果你 一直在使用返回资产的fileuri属性来获取 文件路径在6.x.x之前的版本中,您应该参考 以下是获取路径的另一种方法的问题注释- https://github.com/NativeScript/nativescript-imagepicker/issues/181#issuecomment-384585293 .

        2
  •  0
  •   null Hitesh Sahu    6 年前

    几天来一直在努力解决这个问题…

    这帮我修好了-

    *注意未注释的( //viewModel.uploadFile(file); ) viewModel 参考(在你的应用程序中会有所不同)和功能: uploadFile 例如,您可以在其中传递文件以上载它或将其设置为 image.src

    context
                .authorize()
                .then(function () {
                    return context.present();
                })
                .then(function (selection) {
                    selection.forEach(function (selected) {
    
                        let file;
    
                        if (selected._android) {
    
                            file = fileSystemModule.File.fromPath(selected._android);
                            //viewModel.uploadFile(file);
    
                        }else{
    
                            imageSourceModule.fromAsset(selected).then((imageSource) => {
    
                            const folder = fileSystemModule.knownFolders.documents().path;
                            const fileName = "Photo.png"; 
                            const path = fileSystemModule.path.join(folder, fileName);
                            const saved = imageSource.saveToFile(path, "png");
    
                            if (saved) {
                                console.log("Image saved successfully!");
                                file = fileSystemModule.File.fromPath(path);
                                //viewModel.uploadFile(file);
                            }else{
                                console.log("Error! - image couldnt save.");
                            }
                        });
                    }
                });
                }).catch(function (e) {
                    console.log(e);
                    // process error
                });