未捕获(承诺):[Object object]

时间:2018-06-29 21:50:24

标签: typescript ionic-framework ionic2 ionic3

爱奥尼克(Ionic)有问题,请先谢谢。

每当我按下按钮时就会出现一个按钮,该按钮应该在将照片上传到Firebase后呈现。

错误:未捕获(承诺):[对象对象]

这是我遇到问题的组件的代码:

def dict_of_dicts (filename, keyfield):
    tabledict= {}
    with open (filename, "rt", newline='') as csv_file:
        csvreader=csv.DictReader(csv_file, skipinitialspace=True)
        for row in csvreader:
            tabledict[row[keyfield]]=row
    return tabledict

这是堆栈跟踪:

import { Component, OnInit } from "@angular/core";
import { ActionSheetController } from "ionic-angular";
import { SocialSharing } from "@ionic-native/social-sharing";
import { Pro } from "@ionic/pro";
let urld;
declare var firebase;
@Component({
    selector: "camera-controls",
    templateUrl: "camera-controls.html"
})
export class CameraControlsComponent implements OnInit {
    sheet: any;
    element: HTMLImageElement; /* Defining element */
    constructor(
        private socialSharing: SocialSharing,
        public actionSheetCtrl: ActionSheetController
    ) {}
    ngOnInit(): void {
        const storageRef = firebase.storage().ref();
        function upload() {
            let id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
                c
            ) {
                let r = (Math.random() * 16) | 0,
                    v = c == "x" ? r : (r & 0x3) | 0x8;
                return v.toString(16);
            })
            storageRef.child("images/" + id + ".jpg").put(document.querySelector("input[type=file]")["files"][0]).then(function() {
                storageRef
                    .child("images/" + id + ".jpg")
                    .getDownloadURL()
                    .then(function(url) {
                        console.log(url);
                        urld = url;
                        document.getElementById("preview").setAttribute("src", urld);
                    })
                    .catch(function(error) {
                        Pro.monitoring.exception(new Error(`Error: ${error}`));
                        alert(`Error: ${error}`);
                    });
            });
        }

        document.getElementById("myFileInput").addEventListener("change", upload);
    }

    showShareMenu(): void {
        this.sheet = this.actionSheetCtrl
            .create({
                title: "Modify your album",
                buttons: [
                    {
                        text: "Save",
                        handler: () => {
                            this.socialSharing.saveToPhotoAlbum(urld);
                        }
                    },
                    {
                        text: "Share",
                        handler: () => {
                            this.socialSharing.share(
                                "Made with rushmore.app",
                                "Check out my monument",
                                urld,
                                "https://rushmore.app/?fromSocialShareActionSheet"
                            );
                        }
                    },
                    {
                        text: "Cancel",
                        role: "cancel",
                        handler: () => {
                            console.log("Cancel clicked");
                        }
                    }
                ]
            })
            .present();
    }
}

0 个答案:

没有答案