簡體   English   中英

使用多個承諾的區域符號currentTask Ionic2錯誤

[英]Zone Symbol currentTask Ionic2 error using multiple promises

__zone_symbol__currentTask是什么意思? 我正在使用Ionic2並抓住這個對象看到我的附圖。 我正在嘗試使用多個承諾,這些錯誤與承諾有關嗎?

我還向https://github.com/angular/zone.js/issues/796發送了一個問題

在此輸入圖像描述

useCamera(){

    const getURI = () => {
                const opts: CameraOptions = {
                    quality: 100,
                    mediaType: this.camera.MediaType.PICTURE,
                    encodingType: this.camera.EncodingType.JPEG,
                    destinationType: this.camera.DestinationType.FILE_URI,
                    targetWidth: 200,
                    targetHeight: 200,
                    correctOrientation: true,
                    saveToPhotoAlbum: false
                };

                let promise = new Promise( (resolve, reject) => {
                    this.camera.getPicture(opts)
                    .then( (uri) => {
                    resolve(uri);
                })
                .catch( (err) => { reject(err) });
            });
            return promise;
        }

        // # 2
        const moveFile = (uri) => {
            const _extension = '.' + this.getFileExtension(uri);
            const _name = this.getFileName(uri) + _extension;
            const _newPath = this.myStoragePath;
            const _newName = 'camera_' + this.hashName() + _extension;
            const _uri = uri.substring(0, uri.lastIndexOf('/') + 1);

            let promise = new Promise( (resolve, reject) => {
                this.file.moveFile(_uri, _name, _newPath, _newName)
                .then( (res) => {
                    resolve(res.nativeURL);
                })
                .catch( (err) => {
                    alert('COPY_FILE_CAMERA_ERR ' + JSON.stringify(err));
                    reject(err);
                });
            });
            return promise;
        }

        // # 3
        return getURI().then(moveFile)
    }

    //////////////////////
    // THE CALLER OUTSIDE
    //////////////////////
    this.cameraSettings
        .useCamera() // <------------------ entry point
            .then( (res) => {
              alert('USER.TS_OPEN_CAMERA_SUCC ' + JSON.stringify(res))
            })
            .catch( (err) => {
              alert('USER.TS_OPEN_CAMERA_ERR ' + JSON.stringify(err))
            });

moveTo,copyFile應該調用entryFile而不是this.file參考這篇文章離子1 https://devdactic.com/how-to-capture-and-store-images-with-ionic/ ionic 2 https:// github的.com / AUSdomgarcia / CRUD-ionic2 /斑點/主/ SRC /共享/攝像機settings.service.ts

跳轉到方法useMedia()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM