美文网首页
微信小程序多列

微信小程序多列

作者: _皓月__ | 来源:发表于2020-06-23 15:13 被阅读0次
    <picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
        <view class="picker">
          当前选择:{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}},{{multiArray[2][multiIndex[2]]}}
        </view>
      </picker>
    
      data: {
        multiArray: [['1', '2'], ['1-1', '1-2']],
        multiIndex: [0,0],
      },
      bindMultiPickerChange: function (e) {
        console.log('picker发送选择改变,携带值为', e.detail.value)
        this.setData({
          multiIndex: e.detail.value
        })
      },
      bindMultiPickerColumnChange: function (e) {
        console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
        var data = {
          multiArray: this.data.multiArray,
          multiIndex: this.data.multiIndex
        };
        data.multiIndex[e.detail.column] = e.detail.value;
        if (e.detail.column===0) {
          if (e.detail.value===0) {
            data.multiArray[1] = ['1-1', '1-2'];
            data.multiIndex[1] = 0;
          }else{
            data.multiArray[1] = ['2-1', '2-2'];
            data.multiIndex[1] = 0;
          }
        }
        console.log(data.multiIndex);
        this.setData(data);
      },
    
    image.png

    相关文章

      网友评论

          本文标题:微信小程序多列

          本文链接:https://www.haomeiwen.com/subject/oxdhfktx.html