firebase.auth.GoogleAuthProvider 不是构造函数

2023-12-07

我正在尝试在 Vue 框架中使用 firebase 来使用 google 标志。我不知道这是什么错误,任何人都可以帮助我解决这个问题。

vue.runtime.esm.js?2b0e:1888 TypeError: _firebase_js__WEBPACK_IMPORTED_MODULE_2__.fb.auth.GoogleAuthProvider is not a constructor
at VueComponent.socialLogin (Signin.vue?3d55:76)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at HTMLButtonElement.invoker (vue.runtime.esm.js?2b0e:2179)
at HTMLButtonElement.original._wrapper (vue.runtime.esm.js?2b0e:6917)

这是我的代码

firebase.js

import firebase from "firebase";
var firebaseConfig = {
    config
};
const fb=firebase.initializeApp(firebaseConfig);
export { fb };

登录.vue

<script>
    import { fb } from "../firebase.js";
    export default {
      name: "Signin",
      components: {},
      data() {
        return {
        };
      },
    
      methods: {
         socialLogin() {
       const provider = new fb.auth.GoogleAuthProvider();
    
            fb.auth().signInWithPopup(provider).then((result) => {
              this.$router.replace('home');
            }).catch((err) => {
              alert('Oops. ' + err.message)
            });
          }
      }
    };
    </script>

The auth财产(不是auth()函数)可在静态firebase对象,而不是你的火力基地app.

你想要更多这样的东西

import firebase from "firebase/app"
import "firebase/auth" // ???? this could also be in your `firebase.js` file

const provider = new firebase.auth.GoogleAuthProvider()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

firebase.auth.GoogleAuthProvider 不是构造函数 的相关文章

随机推荐