Vue獲取授權url
阿新 • • 發佈:2020-10-09
1,在vue頁面載入時傳送動態請求獲取微博授權url
1,1 在components\common\lab_header.vue 中寫oauth動態獲取微博授權URL
1 // 獲取微博登入地址 2 oauth() { 3 // 從後端獲取 微博登入地址 oauth_post().then((resp) => { console.log(resp) //{'code': '0', 'msg': '成功', 'data': {'url': url}} let url = resp.data.url; this.weibo_url = url; })View Code4 },
1.2 在vue的mounted函式中呼叫獲取微博授權url函式
mounted() {
this.oauth()
},
1,3 點選"登入"彈出的form表單中加入url
1 <form action="/login" method="post" > <div class="form-group widget-signin"> <a :href="weibo_url"><i class="fa fa-weibo"></i></a> </div> </form>