//下载
npm i vue-google-login
//引入
import GoogleLogin from 'vue-google-login'
//注册
components: {
GoogleLogin
},
//使用
<GoogleLogin
class="bt bt-block _g hover w"
:params="params"
:onSuccess="onSuccess"
>
<img src="../../assets/images/google.png" alt="" />
<strong>
<span v-show="loginAndRegistration">LOG IN</span>
<span v-show="!loginAndRegistration">CONTINUE</span>
WITH GOOGLE</strong
></GoogleLogin
>
//调用方法
async onSuccess (googleUser) {
//获取返回的信息
const user = googleUser.getBasicProfile()
const info = {
email: user.getEmail(),
name: user.getName(),
photo: user.getImageUrl(),
token: user.getId()
}
const res = await store.dispatch('googleGogin', info)
this.isSuccess(res)
},