Small program picker component, you can see that there is a type of objArray in the demo, but it is not used. Now I have a set of objArray that I need to use, but it cannot be displayed normally. Please help me take a look:
Mini program demo link: picker
wxml:
当前选择:{{objectArray[index]}}
js:
Page({ data: { objectArray: [ { id: 0, name: '美国' }, { id: 1, name: '中国' }, { id: 2, name: '巴西' }, { id: 3, name: '日本' } ] }, bindPickerChange: function(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value }) } })
In this case, the displayed drop-down option is [object Object], and the same is displayed on the page after selection. Now I want the drop-down list to display the value in name, and then know the selected id. I really don’t know how to achieve it. . . .
It should be possible to use this attribute. The modified code is as follows:
Update1:
Add range-key='obj.item', for example