关于小程序和后端的简单交互测试基本信息:
微信开发者工具版本:v1.02.2004020
记得勾选:
1.index.wxml
<view><button bindtap="getTest">获取数据</button></view>
<view wx:if="{
{hello!=''}}">{
{hello}}</view>
2.index.js在page中添加
getTest :function(){
var _this= this ;
wx.request({
url: 'http://localhost:8080/hello',
data: {},
header: {'content-type' : 'application/json'},
success: function(res){
console.log(res)
_this.setData({
hello:res.data
})
console.log(_this.data.hello)
}
3后端&#