<picker id="pickerid" @change="pickerChange($event)" :value="aindex" :range="array" range-key="name" style="width:80px"> 紅色部分爲系統聲明的變量 能夠爲多個 此處以列出一個picker
<view class="">
<text class="show-value">{{array[aindex].name}}</text>
</view>
</picker>this
pickerChange: function(e) {//通用picker方法本身添加內容
var nowId = e.target.id;//當前picker的ID id須要本身設置 在picker中spa
var value = e.detail.value;//當前picker選中的值
switch (nowId) {//判斷是哪一個picker 如多個用switch 數量少時可用if
case "pickerid"://第一個picker
this.aindex = value;
break;
case "pickerid2"://第二個picker
this.bindex = value;
break;
case "pickerid3":
this.cindex = value;
break;
}
ci