小程序-循环遍利数据

  1. school.js
Page({
    data:{
      arr: [
        {
          "id": "1001",
          "school": "广州XXX1001学院"
        },
        {
          "id": "1002",
          "school": "广州XXX1002学院"
        },
        {
          "id": "1003",
          "school": "广州XXX1003学院"
        },
        {
          "id": "1004",
          "school": "广州XXX1004学院"
        },
        {
          "id": "1005",
          "school": "广州XXX1005学院"
        },
        {
          "id": "1006",
          "school": "广州XXX1006学院"
        },
        {
          "id": "1007",
          "school": "广州XXX1007学院"
        },
        {
          "id": "1008",
          "school": "广州XXX1008学院"
        },
        {
          "id": "1009",
          "school": "广州XXX1009学院"
        },
        {
          "id": "10010",
          "school": "广州XXX10010学院"
        },
        {
          "id": "10011",
          "school": "广州XXX10011学院"
        },
        {
          "id": "10012",
          "school": "广州XXX10012学院"
        }
      ]
    },
    getschoolid: function (e) {
      var sId = e.target.id;
      console.log('保存学校id:' + sId);
      wx.setStorage({
        key: "schoolId",
        data: sId
      })
//    检测设置成功执行跳转
      wx.getStorage({
        key: 'schoolId',
        success: function (res) {


            //跳转到成功页面
          wx.switchTab({
              url: '../home/home'
            })
            console.log(2222);
        }
      })
    }, onReady: function () {


    },
    onLoad: function(options) {
      var that = this;
      var arrs = that.data.arr;
      that.setData({
        schoollist: arrs
      })

      console.log(21212);
      console.log(arrs);
      console.log(21212);
    }


})
  1. school.xml
<view class="indexs-box">选择校园</view>   
<view wx:for="{{schoollist}}" wx:key="{{index}}" class="xuexiao" >
<button bindtap="getschoolid" id='{{item.id}}' >{{item.school}}</button> 
</view>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值