May 18, 2021 WeChat Mini Program Development Document
The scroll selector that embeds the page
The property name | Type | Description | The lowest version |
---|---|---|---|
value | NumberArray | The numbers in the array represent, in turn, the last item selected by picker-view-colume in picker-view-colume (subsumed from 0), and when the number is greater than the option length of picker-view-column. | |
indicator-style | String | Style the check box in the middle of the selector | |
indicator-class | String | Set the class name of the check box in the middle of the selector | 1.1.0 |
bindchange | EventHandle | When the scroll selection, value changes when the change event is triggered, event.detail is an array that indicates that picker-view-column within picker-view currently selects the first few items (subse cursor starts at 0) |
Note:
Only the components
<picker-view-column/>
and the other nodes will not be displayed.
It can only be
<picker-view />
height of its child node is automatically set to match the height of the picker-view check box.
Example code:
<view>
<view>{{year}}年{{month}}月{{day}}日</view>
<picker-view indicator-style="height: 50px;" style="width: 100%; height: 300px;" value="{{value}}" bindchange="bindChange">
<picker-view-column>
<view wx:for="{{years}}" style="line-height: 50px">{{item}}年</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{months}}" style="line-height: 50px">{{item}}月</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{days}}" style="line-height: 50px">{{item}}日</view>
</picker-view-column>
</picker-view>
</view>
const date = new Date()
const years = []
const months = []
const days = []
for (let i = 1990; i <= date.getFullYear(); i++) {
years.push(i)
}
for (let i = 1 ; i <= 12; i++) {
months.push(i)
}
for (let i = 1 ; i <= 31; i++) {
days.push(i)
}
Page({
data: {
years: years,
year: date.getFullYear(),
months: months,
month: 2,
days: days,
day: 2,
year: date.getFullYear(),
value: [9999, 1, 1],
},
bindChange: function(e) {
const val = e.detail.value
this.setData({
year: this.data.years[val[0]],
month: this.data.months[val[1]],
day: this.data.days[val[2]]
})
}
})