首页 > Web开发 > 详细

vue获取微博授权的URL

时间:2020-11-06 09:45:04      阅读:22      评论:0      收藏:0      [点我收藏+]

1. 在Vue页面加载时动态发送请求获取微博授权url


1.1 在components\commom\lab_header.vue 中写oauth动态获取微博授权URL

	// 获取微博登录地址
	oauth() {
		// 从后端获取 微博登录地址
		oauth_post().then((resp) => {
			console.log(resp)
			// {‘code‘: ‘0‘, ‘msg‘: ‘成功‘, ‘data‘: {‘url‘: url}}
			let url = resp.data.url;
			this.weibo_url = url;
		})
	}

1.2 在vue的mounted函数中调用获取微博授权url函数


	mounted() {
		this.oauth()
	}

1.3 点击"登录"弹出的form表单中加入url

<form
	action=‘/login‘
	methiod=‘post‘ 
>
	<div class="form-group widget-signin">
	<a :href="weibo_url"><i class="fa fa-weibo"></a>
	</div>
</form>

vue获取微博授权的URL

原文:https://www.cnblogs.com/zj555/p/13935006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!