为了账号安全,请及时绑定邮箱和手机立即绑定

vue做的公众号

vue做的公众号

开心每一天1111 2019-03-11 17:19:23
在本地可以访问到接口,但是我要拿code去登录,必须去微信调试工具中登录微信入口拿到code去登录,但是到工具中this.getData(),console.log(12345677)都不出来,cookie是可以写进去的,这是为啥呀。求助,控制台也不报错 什么信息都没有,一片空白,这是我的首页,重定向是到这个页面的created() {        this.getData();        console.log(12345677);        cookies.set('CXC_state','0');//0是认证用户           },    methods: {        getData(){            let json = {}            let _this = this;            base.axios_type("get",json,'/user',function(res){                if(res.code==1){                    console.log(res);                }else if(res.code==-1){                     console.log(11111111111);                    base.wx_logo();                }                            });        },    }base文件function wx_logo(){  let url = location.hostname;  let _this = this;  if(url.indexOf('localhost')!=-1){    location.href = window.location.href;  }else{      location.href =        "https://open.weixin.qq.com/connect/oauth2/authorize?appid=***********8&redirect_uri=https%3a%2f%2&&&&&&&&&&&&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";      let code = ssQueryValueByKey("code");      logo(code);   }};function logo(_code){  let json = {code:_code}  axios_type("get",json,"/getUserInfo",function(res){  console.log(res.msg);  res = JSON.parse(res);  if (res.code == 1) {      //登陆成功      console.log(res.data);  } else if(res.code==-1){  }else {      console.log(res.message);  }  })};function axios_type(requestType,json, url, completion) {  console.log(json);  axios({      method: requestType,      url: 'https://****.******8.com/api'+url,      dataType: "jsonp",      data: JSON.stringify(json),      header:{        "Content-Type":'application/json',      }    }).then(function (res) {        console.log(res.data);        completion(res.data);    }).catch(function (error) {        console.log(error);    });}
查看完整描述

2 回答

?
犯罪嫌疑人X

TA贡献2080条经验 获得超4个赞

访问错服务器地址了,,,,,


查看完整回答
反对 回复 2019-03-29
?
弑天下

TA贡献1818条经验 获得超8个赞

chrome调试工具的console标签,把preserve log选项打开


查看完整回答
反对 回复 2019-03-29
  • 2 回答
  • 0 关注
  • 814 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号