0
我正在嘗試製作自己的條形碼掃描儀應用程序。它應該像Snapchat一樣打開,這基本上意味着當我打開應用時,條形碼掃描器應立即顯示,而不是通過單擊按鈕。 我正在使用科爾多瓦和Ionics,我目前正在使用Phonegap的條形碼掃描器插件,實際上它工作正常,但我無法通過打開應用程序來使其工作。屏幕將只是白色。當我使用按鈕時它正在工作,但在另一個情況下沒有。打開應用程序時打開條形碼掃描儀
我是Cordova和JavaScript的新手,如果你們中的一些人能幫忙,它會幫助我很多!
感謝很多:)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link rel="manifest" href="manifest.json">
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script type="text/javascript">
function scan() {
console.log("clicked");
cordova.plugins.barcodeScanner.scan(function(result) {
//success callback
alert(JSON.stringify(result));
}, function(error) {
//error callback
alert(JSON.stringify(error));
});
}
</script>
</head>
<body ng-app="starter">
<div class="bar bar-header">
<button class="button icon ion-navicon"></button>
<h1 class="title">Header Buttons</h1>
<button class="button">Edit</button>
</div>
<ion-content class="has-header">
<!--<button class="button button-positive" onclick="scan()">Click here to scan</button>-->
<script type="text/javascript">
scan();
</script>
</ion-content>
</body>
</html>
非常感謝:)對我很好:3 – Amiya