1. 程式人生 > >微信小程式-04(後臺訪問-net::ERR_CONNECTION_REFUSED及 不是request合法域名問題 的解決)

微信小程式-04(後臺訪問-net::ERR_CONNECTION_REFUSED及 不是request合法域名問題 的解決)

目錄

用來解決的問題是 不是request的合法域名問題

現在出來這個問題  net::ERR_CONNECTION_REFUSED


小程式這麼寫的

login:function(e){
    const that = this;
    let first, second;
      console.log("登入中...")
      that.data.username= e.detail.value.username,
        that.data.password = e.detail.value.password
      wx.request({
        url: 'http://localhost:8080/login',
        data: {
          username: that.data.username,
          password: that.data.password
        },
        header: {'content-type': 'application/x-www-form-urlencoded'},
        method: 'GET',
        dataType: 'json',
        responseType: 'text',
        success: function(res) {
          console.log("login success!!")
          wx.navigateTo({
            url: '/pages/main/main?username=' + this.data.username
          })   
        },
        fail: function(res) {
        },
        complete: function(res) {},
      })
  }

 

用來解決的問題是 不是request的合法域名問題

使用本地連線localhost等需要配置此處

步驟 工具欄

設定-專案設定-

當不使用用本地連線時

需要去微信公眾平臺 左邊欄的設定裡面去配置裡面的域名資訊

後端程式碼只有這一點

 到這裡就已經解決了不是request合法域名問題

 

現在出來這個問題  net::ERR_CONNECTION_REFUSED

這個問題的解決方式

步驟

在選單欄裡面點選:設定 - 代理設定-下圖

如果不行就 重啟編輯器,還不行重啟電腦,還還不行放棄小程式嘍。