1 <view class='sameBox' id='AREA_SameBox'> 2 <picker bindchange="areaTypeChange" value="{{index}}" range="{{areaArray}}" range-key="{{'name'}}" > 3 <view class="picker"> 4 <text style='color: #c30000'>*</text> 5 <text>国际区位:</text> 6 <input class='_input' disabled="disabled" value="{{areaArray[areaIndex].name}}" /> 7 </view> 8 </picker> 9 </view>
2.js中:
1 areaArray: [{ id: '1', name: '美国' }, { id: '86', name: '中国' }],
2 areaIndex: 10,
3.获取选中的值:
areaTypeChange: function (e) { // 改变国际区号
let inx = e.detail.value;
console.log(this.data.areaArray[inx].id)
this.setData({
areaIndex: e.detail.value,
});
},