# picker

It is now supported to set five scrolling selectors that pop up from the bottom through the mode property: ordinary selector, multi-column selector, time picker, date picker, province/city/district selector. The ordinary selector is used by default.

## mode = selector

Ordinary selector.

|Property name|Type|Default value|Description|
|----|----|-----|---|
|range|Array/Object Array|[ ]|When mode is selector or multiSelector, range is valid|
|range-key|String||When range is an Object Array, the value of key in Object is specified by using range-key as the content of the selector|
|value|Number|0|The value indicates the order of the selected option in the range (subscript starts from 0)|
|bindchange|EventHandler||The change event is triggered when value changes. event.detail = {value: value}|
|disabled|Boolean|false|Whether it is disabled|
|bindcancel|EventHandler||Triggered when collapsing picker is deselected|

## mode = multiSelector

Multi-column selector.

|Property name|Type|Default value|Description|
|-----|---|-----|---|
|range|Two-dimensional Array/Object Array|[ ]|Valid when mode is selector or multiSelector<br> Two-dimensional array, whose length indicates the number of columns. <br>Each item in the array indicates the data of each column, such as [["a","b"], ["c","d"]]|
|range-key|String||Same as the ordinary selector|
|value|Array|[]|The value of each item indicates the order of selected option in each range (subscript starts from 0)|
|bindchange|EventHandler||The change event is triggered when value changes.<br>event.detail = {value: value}|
|bindcolumnchange|EventHandler||The columnchange event is triggered when a value of a column changes. <br>event.detail = {column: column, value: value}. <br>column indicates which column has been changed (subscript starts from 0). <br>value indicates the subscript of the changed value.|
|bindcancel|EventHandler||Triggered when deselected|
|disabled|Boolean|false|Whether it is disabled|

## mode = time

Time picker.

|Property name|Type|Default value|Description|
|-----|---|-----|---|
|value|String||Indicates the selected time in the format of "hh:mm"|
|start|String||Indicates the start of a valid time range in a string format of "hh:mm"|
|end|String||Indicates the end of a valid time range in a string format of "hh:mm"|
|bindchange|EventHandler||The change event is triggered when value changes. event.detail = {value: value}|
|bindcancel|EventHandler||Triggered when deselected|
|disabled|Boolean|false|Whether it is disabled|

## mode = date

Date picker.

|Property name|Type|Default value|Description|
|-----|--|------|---|
|value|String||Indicates the selected date in the format of "YYYY-MM-DD"|
|start|String||Indicates the start of a valid date range in the format of "YYYY-MM-DD" (PC: Supported by Feishu [V5.5](https://open.feishu.cn/document/uYjL24iN/uAjMuAjMuAjM/version-compatibility) and later versions)**|
|end|String||Indicates the end of a valid date range in the format of "YYYY-MM-DD" (PC: Supported by Feishu [V5.5](https://open.feishu.cn/document/uYjL24iN/uAjMuAjMuAjM/version-compatibility) and later versions)**|
|fields|String|day|Valid values are year, month, day, indicating the granularity of the selector|
|bindchange|EventHandler||The change event is triggered when value changes. event.detail = {value: value}|
|bindcancel|EventHandler||Triggered when deselected|
|disabled|Boolean|false|Whether it is disabled|

## mode = region

Region selector. 
**Not supported on PC**

|Property name|Type|Default value|Description|
|-----|--|------|---|
|value|Array||Indicates the selected province, city, or district. By default, the first value in each column is selected|
|custom-item|String||Adds a custom item to the top of each column|
|bindchange|EventHandler||The change event is triggered when value changes.<br>event.detail = {value: value }.|
|bindcancel|EventHandler||Triggered when deselected|
|disabled|Boolean|false|Whether it is disabled|

## Sample code 
The interaction effects of the component on PC and mobile are different. Scan the QR code to preview the display effect on mobile.

```html
<view class="container">
  <view class="page-body">
    <view class="page-section">

<view class="section">
        <view class="section__title">{{custom_picker}}</view>
        <picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">
          <view class="picker">
            {{current_option}}{{array[index]}}
          </view>
        </picker>
      </view>
			<view class="section">
        <view class="section__title">{{custom_object_picker}}</view>
        <picker bindchange="bindObjectPickerChange" value="{{objectIndex}}" range="{{objectArray}}" range-key="en">
          <view class="picker">
            {{current_option}}{{objectArray[objectIndex]['en']}}
          </view>
        </picker>
      </view>

<view class="section">
        <view class="section__title">{{multiSelector}}</view>
        <picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
          <view class="picker">
            {{current_option}}{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}},{{multiArray[2][multiIndex[2]]}}
          </view>
        </picker>
      </view>
      <view class="section">
        <view class="section__title">{{time_picker}}</view>
        <picker mode="time" value="{{time}}" start="{{timeStart}}" end="{{timeEnd}}" bindchange="bindTimeChange">
          <view class="picker">
            {{current_option}} {{time}}
          </view>
        </picker>
      </view>

<view class="section">
        <view class="section__title">{{date_picker}}</view>
        <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindYearDateChange" fields="year">
          <view class="picker">
            {{current_option}} {{yearDate}}
          </view>
        </picker>
      </view>
			<view class="section">
        <view class="section__title">{{date_picker}}</view>
        <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindMonthDateChange" fields="month">
          <view class="picker">
            {{current_option}} {{monthDate}}
          </view>
        </picker>
      </view>
			<view class="section">
        <view class="section__title">{{date_picker}}</view>
        <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDayDateChange" fields="day">
          <view class="picker">
            {{current_option}} {{dayDate}}
          </view>
        </picker>
      </view>
      <view class="section">
        <view class="section__title">Province City District picker</view>
        <picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}">
          <view class="picker">
            {{current_option}}{{region[0]}},{{region[1]}},{{region[2]}}
          </view>
        </picker>
      </view>
    </view>
  </view>

</view>

```

```js
const iPicker = i18n.picker

var ms = [
	[// 0
		'plant',
		'animal'
	],
	[// 1
		[// 1 0
			'tree',
			'grass',
			'vine',
			'flower',
			'leaf'
		],
		[// 1 1
			'fish',
			'amphibian',
			'reptile',
			'test'
		]
	],
	[// 2
		[// 2 0
			['pine', 'sycamore'],
			['rice'],
			['morning glory', 'creeper'],
			['chrysanthemum', 'Overlord flower', 'orchid'],
			['Maple leaf', 'coniferous']
		],
		[// 2 1
			['squid', 'Pike'],
			['frag', 'daxie'],
			['lizard', 'tortoise', 'gecko'],
			[]
		]
	]
];

Page({
	data: {
		array: ['USA', 'China', 'Brasil', 'Japan'],
		index: 0,
		objectArray: [
			{
				id: 0,
				name: 'USA',
				en: 'USA'
			},
			{
				id: 1,
				name: 'China',
				en: 'China'
			},
			{
				id: 2,
				name: 'Brasil',
				en: "Brasil"
			},
			{
				id: 3,
				name: 'Japan',
				en: "Japan"
			}
		],
		objectIndex: 0,
		multiArray: [
			[
				'plant',
				'animal'
			],
			[// 1 0
				'tree',
				'grass',
				'vine',
				'flower',
				'leaf'
			],
			[
				'pine',
				'sycamore'
			],
		],
		multiIndex: [0, 0, 0],
		objectMultiIndex: [0, 0, 0],
		yearDate: '2016',
		monthDate: '2016-09',
		dayDate: '2016-09-01',
		time: '12:01',
		region: ["Beijing", "Beijing", "Chao Yang District"],
		customItem: '--',
		timeStart: '09:01',
		timeEnd: '21:01',
		...iPicker
	},
	topButtopClick() {
		console.log('tappend');
		setTimeout(() => {
			this.setData({
				index: 4,
				array: ['USA', 'China', 'Brasil', 'Japan', 'France'],
				timeStart: "09:03",
				multiIndex: [1, 1, 1]
			})
			console.log('changed');
		}, 5000);
	},
	bindPickerChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			index: e.detail.value
		})
	},
	bindObjectPickerChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			objectIndex: e.detail.value
		})
	},
	bindMultiPickerChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			multiIndex: e.detail.value
		})
	},
	bindMultiPickerColumnChange: function (e) {
		// return;
		console.log('Modified Column:', e.detail.column, ',Value:', e.detail.value);
		var data = {
			multiArray: this.data.multiArray,
			multiIndex: this.data.multiIndex
		};
		switch (e.detail.column) {
			case 0:
				data.multiIndex[0] = e.detail.value;
				data.multiIndex[1] = 0;
				data.multiIndex[2] = 0;

data.multiArray[1] = ms[1][data.multiIndex[0]];
				data.multiArray[2] = ms[2][data.multiIndex[0]][data.multiIndex[1]];
				break;
			case 1:
				data.multiIndex[1] = e.detail.value;
				data.multiIndex[2] = 0;

data.multiArray[2] = ms[2][data.multiIndex[0]][data.multiIndex[1]];
				break;
			case 2:
				data.multiIndex[2] = e.detail.value;
				break;
		}
		this.setData(data);
	},
	bindYearDateChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			yearDate: e.detail.value
		})
	},
	bindMonthDateChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			monthDate: e.detail.value
		})
	},
	bindDayDateChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			dayDate: e.detail.value
		})
	},
	bindTimeChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			time: e.detail.value
		})
	},
	bindRegionChange: function (e) {
		console.log('picker send value:', e.detail.value)
		this.setData({
			region: e.detail.value
		})
	}
})

```

```css
.picker{
  padding: 19rpx 32rpx;
  background-color: #FFFFFF;
}

.section__title{
  padding: 48rpx 32rpx 8rpx 32rpx;
  font-size: medium;
  color: #999999;
}
```

```json
{
    "navigationBarTitleText": "picker"
}

```

