今天来实现一下微信小程序从接口中拿到数据渲染轮播图,原理很简单,一起往下看吧
使用官方给的组件,swiper 滑块轮播,要配合swiper-item一起使用!!
和vue中v-for循环特别相似
上代码:
在index.js中写上接口请求,这里我使用到的是get
Page({
data: {
list:""
},
onLoad:function(options){
let that = this;
wx.request({
url: '接口',
data:{},
method:"GET",
header:{
"content-type":"application/json"
},
success:function(res){
console.log(res.data)
that.setData({
list: res.data.ggto