<picker mode="selector" range="{{classData}}" bindchange="bindClassChange" value="{{classIndex}}" range-key="className">
<view class="picker">
{{classData[classIndex].className || '請選擇班級'}}
</view>
</picker>
classData是接口請求的數(shù)組 如果picker顯示的值是[object,object]這樣的?range-key="className"文章來源:http://www.zghlxwxcb.cn/news/detail-659892.html
range-key就是重點 修改成你要顯示的字段文章來源地址http://www.zghlxwxcb.cn/news/detail-659892.html
//班級選擇
bindClassChange: function (e) {
const classIndex = e.detail.value;
this.setData({
classIndex
});
},
到了這里,關(guān)于微信小程序picker組件的簡單使用 單選的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!