Vue.JS(3)Google Login
I just pick up the simple one, add the dependency in package.json
"vue-google-signin-button": "1.0.2"
Add the script in index.html
<script src="https://apis.google.com/js/api:client.js"></script>
In HelloWorld.vue
<template>
<div>
<g-signin-button
:params="googleSignInParams"
@success="onSignInSuccess"
@error="onSignInError">
Sign in with Google
</g-signin-button>
</div>
</template>
Script part will have all the action, usually I just send the token to server to auth again
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App',
users: [
{firstname: 'Carl', lastname: 'Luo'},
{firstname: 'Rachel', lastname: 'Kang'},
{firstname: 'Leo', lastname: 'Luo'}
],
username: '',
googleSignInParams: {
client_id: ‘44266xxxxx-xxxxxx.apps.googleusercontent.com'
}
}
},
methods: {
onSignInSuccess (googleUser) {
// `googleUser` is the GoogleUser object that represents the just-signed-in user.
// See https://developers.google.com/identity/sign-in/web/reference#users
const profile = googleUser.getBasicProfile() // etc etc
const authResponse = googleUser.getAuthResponse(false)
console.log(profile)
console.log(authResponse)
},
onSignInError (error) {
// `error` contains any error occurred.
console.log('OH NOES', error)
}
}
}
</script>
A very simple CSS in the <style></style>
.g-signin-button {
/* This is where you control how the button looks. Be creative! */
display: inline-block;
padding: 4px 8px;
border-radius: 3px;
background-color: #3c82f7;
color: #fff;
box-shadow: 0 3px 0 #0f69ff;
}
It seems I have everything for the UI part, I just need to refactor and clear my codes.
Some of the documents from google for the response
https://developers.google.com/identity/sign-in/web/reference#gapiauth2authresponse
References:
https://github.com/phanan/vue-google-signin-button
https://github.com/simmatrix/vue-google-auth
分享到:
相关推荐
`vue.global.js` 文件是 Vue.js 框架的核心文件之一。它包含了 Vue.js 全局对象的定义和一些全局方法和属性的实现。 该文件对整个 Vue.js 应用的运行起着重要的作用,它提供了全局范围的 Vue 构造函数和一些全局...
内容:vue.js、vue.min.js、vue.common.js、vue.common.dev.js、vue.common.prod.js、vue.esm.browser.js、vue.esm.browser.min.js、vue.runtime.js、vue.runtime.min.js、vue.runtime.esm.js、vue.runtime.common....
vue.js和vue.min.js
vue.min.js&vue.min.js&vue.common.js&vue.esm.js&vue.runtime.js等 真实资源共计14个js
vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js vue.min.js ...
Explore Vue.js to take advantage of the capabilities of modern browsers and devices using the fastest-growing framework for building dynamic JavaScript applications. You will work with the power of ...
目前社区有很多 Vue.js 的源码解析文章,但是质量层次不齐,不够系统和全面,这本电子书的目标 是全方位细致深度解析 Vue.js 的实现原理,让同学们可以彻底掌握 Vue.js。 为了把 Vue.js 的源码讲明白,课程设计成...
《Vue.js前端框架技术与实战》教学大纲与实训大纲.docx《Vue.js前端框架技术与实战》教学大纲与实训大纲.docx《Vue.js前端框架技术与实战》教学大纲与实训大纲.docx《Vue.js前端框架技术与实战》教学大纲与实训大纲....
<script src="./js/vue%20(1).js" type="text/javascript" charset="UTF-8"> src里面的内容根据自己的下载的Vue.js的文件位置决定的,我这里只是拿我自己做的举个例子。这个地方的vue.js是因为我下载了两次这个版本...
学完本系列课程后,学员将会达到学习目标:只要具有JavaScript基础的学员都能灵活运用Vue.js技术设计前端程序。 实践阶段由浅入深分为四个案例:动态评分、图片轮播、OLTP管理界面、聊天室。聊天室程序则体现了Vue...
前端三大框架之一:Vue.js前端开发 PDF格式,有需要的朋友可以自行下载
vue.min.js官方2.6.14版本
第1章 初识Vue.js 第2章 数据绑定和第一个Vue应用 第3章 计算属性 第4章 v-bind及class与style绑定 第5章 内置指令 第6章 表单与v-model 第7章 组件详解 第8章 自定义指令 第9章 Render函数 第10章 使用webpack 第...
Vue.js 技术揭秘
vue.js和vue.min.js和node.js的安装配置包(详细安装说明请见我的另一个博文node.js和vue.js安装配置)
基于 Vue.js 开发的在线考试管理员后台前端源码 基于 Vue.js 开发的在线考试管理员后台前端源码 基于 Vue.js 开发的在线考试管理员后台前端源码 基于 Vue.js 开发的在线考试管理员后台前端源码 基于 Vue...
Vue.js 架构学习
前端框架vue3的js--vue.global.js
vue实战开发.快速上手.好不容易找到电子版.非PDF版