微信小程序鏈接後臺接口,進行數據交互
新手學微信小程序,設計頁面還可以,有沒有讓進行數據交互的時候就不知道怎麼弄了,下面就記錄一下我是怎麼進行交互的
1.登陸微信小程序平臺,進入首頁,點擊開發設置
2.配置服務器域名
重要的是把配置了 ,後面三個根據需求
3.打開你的小程序項目,點擊詳情,把下面這個打上對勾
4.最後就是js了
data: {
phone: '', //獲取到的手機欄中的值
Code: '',
NewChanges: '',
NewChangesAgain: '',
},
submit:function(){
wx.request({
url: '接口地址',
data: {
'Tel': this.data.phone,
'Password': this.data.NewChanges,
'NewPassword': this.data.NewChangesAgain,
'VerificationCode': this.data.code,
},
method: 'POST',
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
console.log(res.data)
wx.navigateTo({
url: '/rareillness/login/login',//跳轉地址
})
wx.showToast({
title: '提交成功~',
icon: 'loading',
duration: 2000
})
}
})
}