码迷,mamicode.com
首页 > 微信 > 详细

微信小程序多列选择器之range-key

时间:2017-08-01 10:15:36      阅读:949      评论:0      收藏:0      [点我收藏+]

标签:view   修改   change   页面   selector   发送   color   object   dex   

<picker mode="multiSelector" bindchange="bindMultiPickerChange2" bindcolumnchange="bindMultiPickerColumnChange2" value="{{multiIndex}}" range="{{objectMultiArray}}" range-key="{{‘name‘}}">
   <view class="picker">
      当前选择:{{objectMultiArray[0][multiIndex[0]].name}},{{objectMultiArray[1][multiIndex[1]].name}}
   </view>
</picker>

Page({

  /**
   * 页面的初始数据
   */
  data: {
    objectMultiArray: [
      [
        {
          id: 0,
          name: ‘无脊柱动物‘
        },
        {
          id: 1,
          name: ‘脊柱动物‘
        }
      ], [
        {
          id: 0,
          name: ‘扁性动物‘
        },
        {
          id: 1,
          name: ‘线形动物‘
        },
        {
          id: 2,
          name: ‘环节动物‘
        },
        {
          id: 3,
          name: ‘软体动物‘
        },
        {
          id: 3,
          name: ‘节肢动物‘
        }
      ]
    ],
    multiIndex2: [0, 0],
  },


  bindMultiPickerChange2: function (e) {
    console.log(‘picker发送选择改变,携带值为‘, e.detail.value)
    this.setData({
      multiIndex2: e.detail.value
    })
  },
  bindMultiPickerColumnChange2: function (e) {
    console.log(‘修改的列为‘, e.detail.column, ‘,值为‘, e.detail.value);
    var data = {
      objectMultiArray: this.data.objectMultiArray,
      multiIndex2: this.data.multiIndex2
    };
    data.multiIndex2[e.detail.column] = e.detail.value;
    switch (e.detail.column) {
      case 0:
        switch (data.multiIndex2[0]) {
          case 0:
            data.objectMultiArray[1] = [
              { id: 0, name: ‘扁性动物‘ },
              { id: 1, name: ‘线形动物‘ },
              { id: 2, name: ‘环节动物‘ },
              { id: 3, name: ‘软体动物‘ },
              { id: 3, name: ‘节肢动物‘ }
            ];
            // data.multiArray[2] = [‘猪肉绦虫‘, ‘吸血虫‘];
            break;
          case 1:
            data.objectMultiArray[1] = [
              { id: 0, name: ‘鱼‘ },
              { id: 1, name: ‘线形两栖动物‘ },
              { id: 2, name: ‘爬行动物‘ }
            ];
            break;
        }
        data.multiIndex2[1] = 0;
        // data.multiIndex[2] = 0;
        break;
    }
    this.setData(data);
  }

 
})

请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!请记得点赞额!!!

 

 

微信小程序多列选择器之range-key

标签:view   修改   change   页面   selector   发送   color   object   dex   

原文地址:http://www.cnblogs.com/Oopa/p/7266976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!