首页 > 解决方案 > 已安装cordova-plugin-camera,但未安装xcode说插件

问题描述

我正在尝试cordova-plugin-camera开发我的 Ionic 应用程序。我使用cordova plugin add cordova-plugin-camera --save然后安装它npm i --save @ionic-native/camera。该包的 node_modules 文件夹已填充,并且该插件存在于我的所有插件文件夹中,我还验证cordova plugin list了该插件是否显示。我正在使用以下代码尝试启动相机,但它不工作:

import { Component } from "@angular/core";
import { Platform } from "ionic-angular";
import { Camera, CameraOptions } from "@ionic-native/camera";

@Component({
  selector: "page-camera",
  templateUrl: "camera.html"
})
export class CameraPage {
  public base64Image: string;

  constructor(public camera: Camera, public platform: Platform) {}

  takePicture() {
    this.platform.ready().then(() => {
      this.camera
        .getPicture({
          destinationType: this.camera.DestinationType.DATA_URL,
          targetWidth: 1000,
          targetHeight: 1000
        })
        .then(
          imageData => {
            // imageData is a base64 encoded string
            this.base64Image = "data:image/jpeg;base64," + imageData;
          },
          err => {
            console.log(err);
          }
        );
    });
  }
}

运行此程序并单击调用按钮时,takePicture()我没有启动相机,也没有控制台错误,但在 safari 内部,我收到以下错误:

2018-12-13 11:31:24.183490-0500 MyApp[3844:312133] ERROR: Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2018-12-13 11:31:24.183546-0500 MyApp[3844:312133] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["Camera1764610053","Camera","takePicture",[50,0,1,1000,1000,0,0,false,false,false,null,0]]

标签: ioscordovaionic-frameworkcameracordova-plugins

解决方案


重置我的分支并重新安装,成功了。我不确定发生了什么,但认为它只是安装不正确。


推荐阅读