照片选取

[!TIP|labelVisibility:hidden|iconVisibility:hidden] navigator.photoPicker.open(success)

支持平台:

  • Android
  • iOS

参数说明

参数 类型 必填 说明
success Function 回调函数

success函数返回一个对象数组,数组里对象包含以下属性:

  • name(String) -- 图片名称
  • localURL(String) -- 图片本地URL(遵守cdvfile协议)
  • type(String) -- 文件mine type类型
  • lastModifiedDate(String) -- 图片最后被修改的时间
  • size(Number) -- 图片大小,单位 bytes
  • thumbLocalURL(String) -- 缩略图本地URL(遵守cdvfile协议)
  • fullPath(String) -- 图片的全路径(含file:///)

示例代码

// 引用js
<script src='supconit://hcmobile.js'></script>
<script>
    // 监听’deviceready‘事件
    document.addEventListener('deviceready', onDeviceReady, false)
    function onDeviceReady(){
        navigator.photoPicker.open(function(result){
        alert(JSON.stringify(result));
        });
    }
</script>

响应示例代码:

[
 {
   "fullPath": "file:///private/var/mobile/Containers/Data/Application/D679362D-4C7F-40BD-9735-762D12F364A5/tmp/IMG_5629.jpeg",
   "thumbLocalURL": "cdvfile://localhost/root/private/var/mobile/Containers/Data/Application/D679362D-4C7F-40BD-9735-762D12F364A5/tmp/IMG_5629_thumb.jpeg",
   "lastModifiedDate": 1578395518746.0222,
   "size": 195366,
   "localURL": "cdvfile://localhost/root/private/var/mobile/Containers/Data/Application/D679362D-4C7F-40BD-9735-762D12F364A5/tmp/IMG_5629.jpeg",
   "type": "image/jpeg",
   "name": "IMG_5629.JPG"
 }
]

results matching ""

    No results matching ""