cordova imagePicker 使用

小编:管理员 529阅读 2022.09.13

首先html 文件


  
复制
import {ImagePicker} from 'ionic-native';
复制

设置export class ContactPage {} 里面的默认的headface头像

public user={
       username : '',
       userpassword :'' ,
       headface:'images/2.png'  
}
复制
uploadImages(){

   let options = {
                maximumImagesCount: 10,
            };  
  ImagePicker.getPictures(options).then((results) => {
  for (var i = 0; i < results.length; i++) {
      alert('Image URL: ' + results[i]);
  }
}, (err) => { 
    alert('Image ERR: ' + err);
  });
}
复制

注意先要安装imagePicker插件,命令:ionic plugin add cordova-plugin-image-picker

浏览器中看不出效果,要打包

ionic build android 或者cordova build android

后在真机或者模拟器上看

(adsbygoogle = window.adsbygoogle || []).push({});

关联标签: