小程序-picker组件选择数量

    <!-- detail.wxml -->
    <view class="picker">
        <picker range="{{range}}" bindchange="pickerChange">
            选择数量:
            <text>{{num}}</text>
        </picker>
    </view>

    // detail.js
    Page({
        data:{
            range: [ 1, 2, 3, 4, 5, 6, 7, 8, 9],
            num:0,
        },
        pickerChange(e){
            var rangeIndex=e.detail.value;   // 下标
            this.setData({
                num: this.data.range[rangeIndex]
            })
        }
    })

原文地址:https://www.cnblogs.com/wuqilang/p/12074986.html