实现代码:
1,js代码
var ProductTypeArr = []
var ProductTypeIndex = 0
for (var i = 0; i < res.data.ReturnData.T0.length; i++) {
// if (res.data.ReturnData.T0[0].DepartmentID == res.data.ReturnData.T1[i].DepartmentID) {
// ProductTypeIndex = i
// }
ProductTypeArr.push(res.data.ReturnData.T0[i])
}
setTimeout(function () {
_that.setData({
ProductTypeArr: ProductTypeArr,
ProductTypeID: ProductTypeIndex,
})
}, 0)
2,wxml代码
<picker bindchange="bindProductTypeChange" name="ProductTypeID" value="{{ProductTypeID}}"range-key='{{"ProductTypeName"}}' range="{{ProductTypeArr}}">
<view class="weui-select weui-select_in-select-after">{{ProductTypeArr[ProductTypeID].ProductTypeName}}</view>
</picker>