有这样一种方法:
public loadGallery():void{
let options ={
maximumImagesCount: 20,
width: 500,
height: 500,
quality: 75
};
this.imagePicker.getPictures(options).then((result) => {
for (let i = 0; i < result.length; i++) {
this.imgList.push({'win':{id: result[i], title: result[i]}});
}
let builder = new xml2js.Builder();
let xml = builder.buildObject(this.imgList);
this.file.writeFile(this.file.dataDirectory,'mywins.xml', xml, {replace: true});
},
function(errmsg){
console.log('---->'+ errmsg)
});
}
在Android上它可以工作,在iOS上它只在第一次启动时保存,下面只在你拍摄照片时添加到阵列,但文件不会覆盖。