编辑2:
将图像保存到相册使用这个插件:
https://www.npmjs.com/package/cordova-save-image-gallery
https://github.com/agomezmoron/cordova-save-image-gallery/blob/master/README.md
使用的插件,然后将截图插件保存图像。
navigator.screenshot.URI(function(error,res){
if(error){
console.error(error);
}else{
var params = {data: res, prefix: 'myPrefix_', format: 'JPG', quality: 80, mediaScanner: true};
window.imageSaver.saveBase64Image(params, function (filePath) {
console.log('File saved on ' + filePath);
},
function (msg) {
console.error(msg);
}
);
}
}, 'jpg', 50);
编辑:
我不认为我正确的理解这个问题。
我不认为你将能够在iOS上导航到目录。相反,您需要将数据作为URI并使用相机插件之类的东西将其存储在照片库中。
那就是如果你想查看图像?我认为这个插件的设计目的只是为你返回一个截图并将其保存在应用程序的临时目录中。您可以选择显示图像或将其存储在其他位置。
原来的答案
我认为这个问题是仅适用于iOS采用JPG格式,并且不指望“JPG”的说法。试着改变你的代码
navigator.screenshot.save(function(error, res)
{
if(error)
{
alert(error);
}
else
{
alert(res.filePath); //just to see the path
}
});
此外,在iOS上,所获得的路径是:/私营/无功/移动/集装箱/数据/应用/一些代码(25BF5D81 -......)的/ tmp /” screenshotname'.jpg – Alcadeias