mand-mobile/components/picker
hangzou 7c3d50216a
feat(chore): ui,color upgrade (#755)
* feat: update ui

* fix(icon): fix refresh icon
2021-08-06 14:34:26 +08:00
..
demo feat(chore): ui,color upgrade (#755) 2021-08-06 14:34:26 +08:00
mixins feat(core): 添加默认国际化的支持 (#729) 2021-03-02 13:27:32 +08:00
test feat(picker & date-picker): add prop keep-index (#580) 2019-09-20 14:39:26 +08:00
README.en-US.md doc(picker & date-picker): add version mark to keep-index 2019-09-20 15:49:32 +08:00
README.md doc: fix docs words error 2020-09-17 11:58:35 +08:00
cascade.js examples(picker): demo (#419) 2019-04-22 23:57:20 +08:00
component.js Initial commit 2018-03-26 16:04:04 +08:00
index.vue feat(picker & date-picker): add prop keep-index (#580) 2019-09-20 14:39:26 +08:00
picker-column.vue fix(picker&date-picker): handling when rolling too fast & remove redu… (#633) 2020-01-08 15:03:40 +08:00

README.en-US.md

title preview
Picker https://didi.github.io/mand-mobile/examples/#/picker

Scrollable multi-column selector

Import

import { Picker } from 'mand-mobile'

Vue.component(Picker.name, Picker)

Code Examples

API

Picker Props

Props Description Type Default Note
v-model display picker or not Boolean false -
data data source Array<{value, label, ...}>[] [] -
cols number of columns Number 1 -
default-index indexes of initially selected items in each column Array [] -
default-value values of initially selected items in each column Array [] Available key text/label/value
invalid-index indexes of disabled items in each column Array [] array of multiple disabled items, such as [[1,2], 2]
is-view inline display in page, otherwise it shows as Popup Boolean false -
is-cascade data in each column is cascaded or not Boolean false see #Appendix for the format of cascaded data
keep-index 2.5.2+ keep last stop position when the column data changes Boolean false only for cascaded data
line-height line height of options Number 45 unit px
title title of picker String - -
describe description of picker String - -
ok-text confirmation text String confirm -
cancel-text cancellation text String cancel -
large-radius 2.4.0+ large radius of title bar Boolean false -
mask-closable picker will be closed when clicking mask Boolean true -

Picker Methods

refresh(callback, startColumnIndex)

Reinitialized picker, like updating datadefault-indexinvalid-index or call setColumnValuesit can also be replaced with key

Parameters Description Type
callback initialization completes callback Function
startColumnIndex the starting index of the column to reset, default value is 0 Function
getColumnValue(index): activeItemValue

Get the data of the currently selected item in a column, need to be called after the initialed event is invoked or asynchronously called

Parameters Description Type
index the index of each column Number

Returns

Props Description Type
activeItemValue value of selected item Object: {value, label, ...}
getColumnValues(): columnsValue

Get values of all selected columns, need to be called after the initialed event is invoked or asynchronously called

Returns

Props Description Type
columnsValue values of all selected columns Array<{value, label, ...}>
getColumnIndex(index): activeItemIndex

Get the index of the currently selected item in the column, need to be called after the initialed event is invoked or asynchronously called

Parameters Description Type
index the index of column Number

Returns

Props Description Type
activeItemIndex the index of selected item Number
getColumnIndexs(): columnsIndex

Get indexes of all selected columns, need to be called after the initialed event is invoked or asynchronously called

Returns

Props Description Type
columnsIndex indexes of all selected columns Array
setColumnValues(index, values, callback)

Set column data

Parameters Description Type
index the index of each column Number
values data of each column Array<{value, label, ...}>
callback callback is completed after setting values Function

Picker Events

@initialed()

Initialize picker, callable functions are getColumnIndex, getColumnIndexs, getColumnValue, getColumnValues

@change(columnIndex, itemIndex, value)

Change pickers' selections

Parameters Description Type
columnIndex the index of changed column Number
itemIndex the index of changed item in the column Number
value the value of changed item in the column Object: {value, label, ...}
@confirm(columnsValue)

Confirm picker's selection (only when is-view is false

Parameters Description Type
columnsValue values of all selected columns Array<{value, label, ...}>
@cancel()

Cancel picker's selection (only when is-view is false

@show()

Show picker (only when is-view is false

@hide()

Hide picker (only when is-view is false

Appendix

  • The format of non-cascade data source
[
  [
    {
      // Option display text
      "text": "",
      // custom fields
      "value": ""
    },
    // ...
  ],
  // ...
]
  • The format of cascaded data source
[
  [
    {
      // ption display text
      "text": "",
      // data of second column
      "children": [
        {
          "text": "",
          // data of third column
          "children": [
            // ...
          ]
        },
        // ...
      ]
      // custom fields
      "value": ""
    },
    // ...
  ]
]