我正在使用PhoneGap展示一个打开相机的按钮:
document.addEventListener("deviceready", loaded, false);
function loaded() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
function capturePhoto() {
navigator.camera.getPicture(getPhoto, onFail, {
quality : 50
});
}
function getPhoto(imageData) {
alert(imageData);
var smallImage = document.getElementById('cameraPic');
smallImage.style.display = 'block';
smallImage.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
<body>
<div id="camera">
<button class="camera-control" onclick="capturePhoto();">CapturePhoto</button>
<div style="text-align: center; margin: 20px;">
<img id="cameraPic" src="" style="width: auto; height: 120px;"> <img>
</div></div>
</body>
当点击按钮时,我希望能够解码QR代码并在我的页面上显示解码后的值。我想仅使用JavaScript和PhoneGap来实现这一点,而不想使用任何本地代码。