我正在尝试在我的phonegap的基本hello world应用程序中使用screenshot.js。但是我无法从我的app.i试图实现这个三天以来的截图。我尝试了从应用程序截取屏幕截图的所有三种方法但是失败。请帮助。我的代码是:
<head>
<script type="text/javascript">
// Method #1 ...which should work .but didn't
window.plugins.Screenshot.saveScreenshot();
// Method #2 ...
window.plugins.screenshot.save(function(error,res){
if(error){
alert(error);
}else{
alert('ok',res.filePath); //should be path/to/myScreenshot.jpg
}
},'jpg',50,'myScreenShot');
</script>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="Screenshot.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
// Method #3 ...
navigator.screenshot.save(function(error,res){
if(error){
console.error(error);
}else{
console.log('ok',res.filePath);
}
});
</body>