Error loading firebase js with requirejs

前端 未结 1 408
情书的邮戳
情书的邮戳 2021-01-21 13:11

I load Firebase js library with RequireJS like this:

require([
    \'firebase-app\',
    \'firebase-storage\'
], function (firebase) {
    firebase.initializeApp         


        
相关标签:
1条回答
  • 2021-01-21 13:34

    Found the solution at this page (valid only for firebase release >= 5.5.6):

    https://github.com/firebase/firebase-js-sdk/issues/1266#issuecomment-441405513

    you must call firebase.app.js like "@firebase/app", so:

    var config = {
        paths: {
            '@firebase/app': 'https://www.gstatic.com/firebasejs/5.7.1/firebase-app',
            '@firebase/storage': 'https://www.gstatic.com/firebasejs/5.7.1/firebase-storage'
        }
    };
    require([
        '@firebase/app',
        '@firebase/storage'
    ], function (firebase) {
        firebase.initializeApp({
            ...
        });
    
        firebase.storage();
    });
    

    final jsfiddle: https://jsfiddle.net/ptmw0srq/125/

    0 讨论(0)
提交回复
热议问题