微信小程序的picker使用数组作为选项

页面:


<picker 
	bindchange="bindCountryChange" 
	class="weui-input weui-right" 
	value="{{countryIndex}}" 
	range="{{countries}}" 
	range-key="name"
>
    <viewclass="weui-select ">{{countries[countryIndex].name}}</view>
</picker>

data:{
	countries: [
            {id: 1,  name: "餐饮费",},
            {id: 2,  name: "住宿费",}
        ],
        countryIndex: 0,
}
bindCountryChange(e){
            this.setData({
            countryIndex:  e.detail.value
        })
    },

 

你可能感兴趣的