Vue获取微博授权URL

 

  1. 在components/common/lab_header.vue中写oauth动态获取微博授权URL

# 获取微博登录地址
oauth(){
   # 从后端获取 微博登录地址
   oauth_post().then((resp) => {
       console.log(resp)
       # {'code':'0', 'msg':'成功', 'data':{'url':url}}
       let url = resp.data.url;
       whid.weibo_url = url
  })
}
  1. 在vue的mounted函数中调用获取微博授权url函数

mounted(){
   this.oauth()
},
  1. 点击 “登录” 弹出的form表单中加入url

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

 

posted @ 2020-10-11 21:18  CefiLing  阅读(70)  评论(0)    收藏  举报