q968 发表于 2017-7-8 15:36:09

ionic 打开系统相册 mac

  首先在终端打开项目然后执行如下代码:



cordova plugin add https://github.com/wymsee/cordova-imagePicker.git
  方法(methods)



getPictures(options)
  options




参数
类型
解释


maximumImagesCount
Integer
最大选择图片数量


width 或height
Integer
筛选宽度或高度如果宽或高为0返回原有尺寸图片


quality
Integer
  图像质量的大小,默认为100




  代码示例



module.controller('ThisCtrl', function($scope, $cordovaImagePicker) {
var options = {
maximumImagesCount: 10,
width: 800,
height: 800,
quality: 80
};
$cordovaImagePicker.getPictures(options)
.then(function (results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results);//返回参数是图片地址 results 是一个数组
}
}, function(error) {
// error getting photos
    });
});
  参考资料:http://www.ionic-china.com/ngCordova/Image%20Picker.html
  http://ngcordova.com/docs/plugins/imagePicker/
页: [1]
查看完整版本: ionic 打开系统相册 mac