无法读取未定义的属性'getPicture'

问题描述 投票:0回答:1

在打开本主题之前,我在这里阅读了几个答案,但所有答案都是很老,没有一个工作。

我是Cordova的新手。

我正在尝试使用cordova-plugin-camera插件

我生成了apk,当我要在手机上测试它(MotoG 3-Android 6.0时,它没有打开。

使用调试显示此错误:

无法读取未定义的属性'getPicture']

此代码:

<!DOCTYPE html>
<html>
  <head>
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="shortcut icon" href="img/favicon.png"  />

    <title>Foto</title>
  </head>
  <body>

    <div class="app">

      <button type="button" class="btn" id="cameraApp">Take a picture</button>
      <img src="" id="myImage">


    </div>




    <script src="js/jquery-3.4.1.min.js"></script>

    <script>

      document.getElementById('cameraApp').addEventListener('click', cameraApp);
      function cameraApp() {
        navigator.camera.getPicture(onSuccess, onFail,{
          quality: 100,
          saveToPhotoAlbum: true,
          destinatinType: Camera.DestinatinType.DATA_URL
        });

        function onSuccess(imageData){
          var image = document.getElementById('myImage');
          image.src = "data:image/jpeg;base64," + imageData;
        }

        function onFail(message){
          alert('Falhou: ' + message);
        }
      }

    </script>


  </body>
</html>

CONFIG.XML

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android" >
    <name>F.C. APP</name>
    <description>
        Myapp
    </description>
    <author email="[email protected]" href="www.mysite.net">
        Hostcia.net
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon src="www/img/favicon.png" width="57" height="57" density="mdpi" />
        <custom-config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.INTERNET" />
            <uses-permission android:name="android.permission.NETWORK_ACCESS" />
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <uses-permission android:name="android.permission.CAMERA" />
            <uses-feature android:name="android.hardware.camera" />
            <uses-feature android:name="android.hardware.camera.autofocus" />
          </custom-config-file>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

我在做什么错?

在打开本主题之前,我在这里阅读了几个答案,但是所有答案都很老,没有一个起作用。我是科尔多瓦的新手。我正在尝试使用cordova-plugin-camera插件。我生成apk,并且当...

cordova cordova-plugins
1个回答
0
投票

[navigator设备就绪事件后可用

© www.soinside.com 2019 - 2024. All rights reserved.