对于一个学校项目,我必须在PhoneGap.Build中创建一个应用程序,但我真的很难说。我需要实现的一件事是相机。不必保存图片或其他任何东西,只需激活相机即可。
我遵循了下面的教程https://royduineveld.nl/app-maken-met-phonegap-en-phonegap-build/,该教程是荷兰语的,相当古老,但是我浏览了不同的论坛,发现了类似https://community.adobe.com/t5/PhoneGap/cordova-plugin-camera-not-working-on-android-device/td-p/9723868#10341001的内容。我现在已经尝试了很多解决方案,但是似乎没有任何效果。我也尝试阅读该插件上的文档,但是很难理解。我没有javascript的基本知识,也不属于我学校的课程。显然我一定做错了,但是我不知道该怎么办。此刻,我只有一个带有按钮的屏幕,当我按下它时,似乎什么也没发生。请帮帮我。您将在下面找到代码:
(function() {
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady()
{
}
function cameraSuccess(imageData)
{
$('#maak-foto').after('<img src="' + "data:image/jpeg;base64," + imageData + '">');
}
function cameraError(message)
{
alert('Er ging iets fout! ' + message);
}
$('#maak-foto').click(function()
{
$('img').remove();
navigator.camera.getPicture( cameraSuccess, cameraError, {
quality: 50, // Foto kwaliteit
destinationType: Camera.DestinationType.DATA_URL // Base64 gecodeerde afbeelding als resultaat
});
});
})();
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Foto maken</title>
</head>
<body>
<div class="app">
<h1>Foto!</h1>
<button id="maak-foto">Maken</button>
</div>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
< http://www.w3.org/ns/widgets” xmlns:gap =“ http://phonegap.com/ns/1.0” id =“ com.phonegap.hello-world” 版本=“ 1.0.0”>
<name>Camera App</name>
<description>
Camera example app.
</description>
<author href="<a href="http://phonegap.com" target="_blank">http://phonegap.com</a>" email="support@phonegap.com">
PhoneGap Team
</author>
<feature name="<a href="http://api.phonegap.com/1.0/camera"/" target="_blank">http://api.phonegap.com/1.0/camera"/</a>>
<plugin name="cordova-plugin-camera" source="npm"/>