【问题标题】:Use the windows phone 8.1 camera With Ionic Framework使用带有 Ionic 框架的 windows phone 8.1 摄像头
【发布时间】:2016-01-20 19:49:40
【问题描述】:

我正在使用 ionic 框架创建一个应用程序。

我需要使用设备的摄像头。

我在 Android 上做了测试,没有问题。

但在 windows phone 8.1 上无法使用相机。我正在使用的代码 在下面。

cordova 插件添加 org.apache.cordova.camera

添加依赖

   angular.module('starter.menu', ['starter.services', 'ngCordova'])

<script src="js/lib/ng-cordova.min.js"></script>

$scope.takePicture = function () {
        var options = {
            quality: 100,
            destinationType: Camera.DestinationType.DATA_URL,
            sourceType: Camera.PictureSourceType.CAMERA,
            allowEdit: true,
            encodingType: Camera.EncodingType.PNG,
            targetWidth: 600,
            targetHeight: 600,
            popoverOptions: CameraPopoverOptions,
            saveToPhotoAlbum: false,
            correctOrientation: true
        };
    $cordovaCamera.getPicture(options).then(function (imageData) {
        var image = document.getElementById('myImage');
        $scope.imgURI = "data:image/jpeg;base64," + imageData;
    }, function (err) {

        console.log("CAMERA ERROR - " + JSON.stringify(err));
    });
}

我的观点

<ion-view cache-view="false" view-title="Title">
        <ion-content style="margin : 5px !important;">
            <img ng-show="imgURI !== undefined" ng-src="{{imgURI}}">
            <img ng-show="imgURI === undefined" width="100%" ng-src="./img/placehold-800x500.jpg">
            <button class="button" ng-click="takePicture()">Picture</button>
        </ion-content>
    </ion-view>

错误:JavaScript 运行时错误:NotFoundError

【问题讨论】:

    标签: cordova camera windows-phone-8.1 ionic-framework


    【解决方案1】:
    navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
    

    来源:https://github.com/apache/cordova-plugin-camera#module_camera.getPicture

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-09
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多