国际项目会用到一些第三方登录api,这次记录Line的!操作步骤:注册Line账号我就不说了,虽然麻烦,但我自己想办法!demo请点这里http://download.lllomh.com/cliect/#/product/J417081951162505一:开发者平台配置去Line的开发者平台新建一个App:https://developers.line.biz/en/顺便写下资料:动态demo:这是需要用到的2个东西:ChannelID和Channelsecret对应'client_id'=>'5431649755','client_secret'=>'234b6e64c13285e6d058ff7b1bbc8e'key就是这里的重定向地址应该填写(几乎所有第三方要求):二:代码部署核心获取第三方部分一:组件封装:1、开始:这里是const{code}=queryString。parse(window.location.search.replace('?',''))if(!code)return这里页面回调刷新时,如果url有这个code值,就会执行获取token的方法,否则不会执行:asynccreated(){const{code}=queryString.parse(window.location.search.replace('?',''))if(!code)returnconstresult=awaitthis.getToken(code)const{data}=awaitthis.getProfile(result.token)if(this.friendRequired){constflag=awaitthis.checkFriend(result.token)if(!flag){this.error=this.friendErrorTest}}if(!this.error){constresponse=Object.assign(data,result.getPostable())this.$emit('result',response)}},asyncgetToken(代码){constresult=newOAuthRequest({code:code,clientId:this.clientId,clientSecret:this.clientSecret,redirectUri:this.callbackUri})constparams=newURLSearchParams()linq.from(result.getPostable()).选择(x=>params.append(x.key,x.value)).toArray()const{data}=awaitaxios.post('https://api.line.me/oauth2/v2.1/token',params)console.log(data,"data")//在这里获取返回的第三方结果个人信息returnnewOAuthResult(data)},二:组件封装:1、组件使用:除三个参数外,有的看修改整合