代码拉取完成,页面将自动刷新
The Screenshot plugin allows your application to take screenshots of the current screen and save them into the phone.
install it via cordova cli
cordova plugin add https://github.com/gitawego/cordova-screenshot.git
notice: in iOS, only jpg format is supported in Android, the default WebView and Crosswalk are both supported
navigator.screenshot.save(function(error,res){
if(error){
console.error(error);
}else{
console.log('ok',res.filePath);
}
});
take screenshot with jpg and custom quality
navigator.screenshot.save(function(error,res){
if(error){
console.error(error);
}else{
console.log('ok',res.filePath);
}
},'jpg',50);
define a filename
navigator.screenshot.save(function(error,res){
if(error){
console.error(error);
}else{
console.log('ok',res.filePath); //should be path/to/myScreenshot.jpg
}
},'jpg',50,'myScreenShot');
screenshot files are stored in /sdcard/Pictures for android.
take screenshot and get it as Data URI
navigator.screenshot.URI(function(error,res){
if(error){
console.error(error);
}else{
html = '<img style="width:50%;" src="'+res.URI+'">';
document.body.innerHTML = html;
}
},50);
.service('$cordovaScreenshot', ['$q', function ($q){
return {
capture: function (filename, extension, quality){
extension = extension || 'jpg';
quality = quality || '100';
var defer = $q.defer();
navigator.screenshot.save(function (error, res){
if (error) {
console.error(error);
defer.reject(error);
} else {
console.log('screenshot saved in: ', res.filePath);
defer.resolve(res.filePath);
}
}, extension, quality, filename);
return defer.promise;
}
};
}])
add this line <preference name="CrosswalkAnimatable" value="true" />
in config.xml, see bug
this repo uses the MIT license
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。