gapi is not defined - Google sign in issue with gapi.auth2.init

后端 未结 6 1509
死守一世寂寞
死守一世寂寞 2020-11-29 05:07

I\'m trying to implement Google Sign In and retrieve the profile information of the user. The error is: Uncaught ReferenceError: gapi is not defined. Why is that?



        
6条回答
  •  星月不相逢
    2020-11-29 05:34

    For a Vue.JS app

    • Add an onload hook to the script tag for platform.js
    • Set up a function that dispatches an event
    • Catch that event in the mounted hook of your component.

    Here's a fairly complete example you can just paste into a new vue-cli project.

    Don't forget to supply your own client ID!

    public/index.html

        
        
        
    
    

    App.vue

    
    
    
    
    
    

提交回复
热议问题