1

在 HTML/Cordova 应用程序的上下文中:在 iOS 11.3 之前,您可以在 html 中使用 type="file" 的输入来打开 iOS 中的照片库并选择图像。然后使用 FileReader 您可以在回调中对获取的图像做一些事情。

现在在 11.3+ 中,当文件在您的回调中加载时:它返回一个无用的 object {isTrusted: true}。见下文:

function imageFetchSuccess(files) {
  var file = this.files[0];
  var reader = new FileReader();
  reader.readAsDataURL(file);
  reader.onloadend = function(data) {

    // you used to be able to get your image like this and do something with it
    var img = data.currentTarget.result;

    // but now what's returned for 'data' is {isTrusted: true}
  };
}

我尝试过调整但没有成功。是否仍然可以在不使用另一个 Cordova 插件的情况下使用此策略获取图像?

4

1 回答 1

0

所以事实证明你所需要的var img = reader.result;只是var img = data.currentTarget.result;

于 2018-06-17T00:39:38.337 回答