收藏
回答

Error: onPageNotFound error: page "pages/login...?

json里面只注册了一个页面

这里面是个很干净的项目我就在app.js里面加了点东西

要说login的话也就只有最后一个函数里用了wx:login了,我没有这个login页面,他为啥要一直找这个页面?

求解!

getOpenId: function () {
    var that = this
    wx.login({
      successfunction (res{
        if (res.code) {
          wx.getUserInfo({
            successfunction (res{
              console.log(res.userInfo);
              wx.setStorageSync('userInfo', res.userInfo); //存储userInfo
            }
          });
          //这里存储了appid、secret、token串  
          var url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + that.globalData.appid + '&secret=' + that.globalData.secret + '&js_code=' + res.code + '&grant_type=authorization_code';
          wx.request({
            url: url,
            data: {},
            method'GET'// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT  
            // header: {}, // 设置请求的 header  
            successfunction (res{
              var obj = {};
              obj.openid = res.data.openid;
              obj.expires_in = Date.now() + res.data.expires_in;
              console.log(obj);
              wx.setStorageSync('user', obj); //存储openid  
              that.globalData.openid = res.data.openid;
            }
          });
        } else {
          console.log('获取用户登录态失败!' + res.errMsg)
        }
      }
    });
  }
回答关注问题邀请回答
收藏

1 个回答

  • 鲤子
    鲤子
    发表于小程序端
    2021-03-19

    重启一下工具

    2021-03-19
    有用 2
    回复 3
    • 愿你归来仍少年
      愿你归来仍少年
      2021-03-19
      解决了,谢谢,在那个project .pravite.js 里有那么个路径,我也不知道怎么进去的,我没设置过,前脚都能用,现在删掉了就好了
      2021-03-19
      回复
    • 鲤子
      鲤子
      2021-03-19回复愿你归来仍少年
      这个是开发工具编译模式的配置文件
      2021-03-19
      回复
    • 楼上小蒋
      楼上小蒋
      2021-04-01回复愿你归来仍少年
      俺也一样,注册了页面,然后改了个名字就报错
      2021-04-01
      回复
登录 后发表内容
问题标签