微信小程序picker使用问题

微信小程序picker使用的时候可以像用select一样判断那一项被选中了吗

<view class="list">
      <picker bindchange="educationChange" value="{{index}}" range="{{education}}">
        <view class="picker">
          <text class="picker-title" data-id="{{education[index]}}">学历</text>:{{education[index]}}
        </view>
      </picker>
    </view>

js里面想像angular一样直接判断哪一项被选中了,求教一下,下面代码if里面那样写不行。如果不能直接判断哪一项被选中了,帮忙讲讲别的思路,谢谢了。

 a.forEach(function(item){
         item.option.forEach(function(item){
            if(item.select){
              console.log(1)
              }
           }
        }
      
阅读 15.9k
4 个回答

请问怎么获取data-id="{{education[index]}}" 的值呢

bindchange 肯定是切换这组数据的选中角标 index
根据 index 的值不就可以判断哪一项是选中项了么

新手上路,请多包涵

同问,请问怎么获取data-id="{{education[index]}}" 的值呢?为什么我获取的 console.log('data-id', e.detail.data-id)是underfined呢

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题