wxml
<view wx:for="{{data}}">
{{item}}
</view>
wx.js
Page({
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
wx.request({
url: 'http://localhost:8080/wxjdbc',
data:{},
method:'GET',
header:{
'content-type' : 'application'
},
success: function(res){
that.setData({
data:res.data,
});
}
})
}
})
springboot 后台
项目名 叫wxsql
源代码与https://blog.youkuaiyun.com/qw160/article/details/108825246 一样,只改了@requestmapping

本文介绍了一个使用WXML结合WX.JS进行数据请求的具体案例,通过wx:for循环展示从SpringBoot后台获取的数据。展示了页面生命周期函数onLoad中发起HTTP请求的方法,并设置了请求头为application类型。
3万+

被折叠的 条评论
为什么被折叠?



