Skip to content

Cascader

A tab-switching hierarchical selector component that supports unlimited levels of cascading and lazy loading. Features a bottom-sheet popup panel with tab navigation for switching between levels. Ideal for scenarios like region selection and organizational structure selection.

Platform Differences

App (vue)App (nvue)H5Mini Program

Basic Usage

  • Pass tree-structured data via options, and bind the selected value path array using v-model.
  • The panel automatically confirms and closes after selecting a leaf node.
html
<see-cascader v-model="value" :options="options" />

<script lang="ts" setup>
import { ref } from 'vue'

const value = ref<(string | number)[]>([])
const options = [
  {
    value: 'zhejiang',
    text: 'Zhejiang',
    children: [
      {
        value: 'hangzhou',
        text: 'Hangzhou',
        children: [
          { value: 'xihu', text: 'Xihu District' },
          { value: 'yuhang', text: 'Yuhang District' }
        ]
      },
      {
        value: 'ningbo',
        text: 'Ningbo',
        children: [
          { value: 'haishu', text: 'Haishu District' },
          { value: 'yinzhou', text: 'Yinzhou District' }
        ]
      }
    ]
  },
  {
    value: 'jiangsu',
    text: 'Jiangsu',
    children: [
      {
        value: 'nanjing',
        text: 'Nanjing',
        children: [
          { value: 'xuanwu', text: 'Xuanwu District' },
          { value: 'gulou', text: 'Gulou District' }
        ]
      }
    ]
  }
]
</script>

Lazy Loading

  • Set isLazy to true to enable lazy loading mode.
  • Pass an async loading function via lazyLoad. The function receives the current node and returns an array of child options.
  • The isLeaf field in the option data indicates whether a node is a leaf node.
html
<see-cascader
  v-model="value"
  :options="options"
  isLazy
  :lazyLoad="loadChildren"
/>

<script lang="ts" setup>
import { ref } from 'vue'

const value = ref<(string | number)[]>([])
const options = [
  { value: 'zhejiang', text: 'Zhejiang', isLeaf: false },
  { value: 'jiangsu', text: 'Jiangsu', isLeaf: false }
]

async function loadChildren(node: any) {
  // Simulate async request
  return new Promise((resolve) => {
    setTimeout(() => {
      if (node.value === 'zhejiang') {
        resolve([
          { value: 'hangzhou', text: 'Hangzhou', isLeaf: false },
          { value: 'ningbo', text: 'Ningbo' }
        ])
      } else {
        resolve([
          { value: 'nanjing', text: 'Nanjing' },
          { value: 'suzhou', text: 'Suzhou' }
        ])
      }
    }, 500)
  })
}
</script>

Custom Configuration

  • Set the title via toolbarTitle.
  • Customize button text via confirmText and cancelText.
  • Set isShowTab to false to hide the level tab navigation.
  • Customize field mapping via valueKey, labelKey, and childrenKey.
html
<see-cascader
  v-model="value"
  :options="options"
  toolbarTitle="Select Region"
  confirmText="Confirm"
  cancelText="Close"
  :isShowTab="false"
/>

Disabled Options

  • Set disabled to true in the option data to disable a single option.
  • Set isDisabled on the component to disable the entire selector.
html
<see-cascader v-model="value" :options="options" />
<see-cascader v-model="value" :options="options" isDisabled />

<script lang="ts" setup>
import { ref } from 'vue'

const value = ref<(string | number)[]>([])
const options = [
  {
    value: 'zhejiang',
    text: 'Zhejiang',
    children: [
      { value: 'hangzhou', text: 'Hangzhou' },
      { value: 'ningbo', text: 'Ningbo', disabled: true }
    ]
  }
]
</script>

API

Props

ParameterDescriptionTypeDefault
modelValueSelected value path array (v-model)(string | number)[][]
optionsOption data (tree structure)CascaderOption[][]
placeholderPlaceholder textstring'Please select'
isDisabledWhether disabledbooleanfalse
isReadonlyWhether readonlybooleanfalse
isShowToolbarWhether to show the top toolbarbooleantrue
toolbarTitleToolbar titlestring''
confirmTextConfirm button textstring'Confirm'
cancelTextCancel button textstring'Cancel'
valueKeyKey name for valuestring'value'
labelKeyKey name for labelstring'text'
childrenKeyKey name for childrenstring'children'
isLazyWhether to lazy-load child optionsbooleanfalse
lazyLoadLazy loading function(node: CascaderOption) => Promise<CascaderOption[]>-
sizeSize'small' | 'default' | 'large''default'
isBorderWhether to show borderbooleantrue
nameForm field namestring''
isShowTabWhether to show level tab navigationbooleantrue

CascaderOption Type Definition:

FieldDescriptionTypeRequired
valueOption valuestring | numberYes
textOption textstringYes
disabledWhether disabledbooleanNo
isLeafWhether it is a leaf node (used in lazy loading mode)booleanNo
childrenList of child optionsCascaderOption[]No

Events

EventDescriptionCallback Parameters
onChangeTriggered when the value changesvalue: (string | number)[]
onConfirmTriggered when the confirm button is clickedvalue: (string | number)[]
onCancelTriggered when the cancel button or overlay is clicked-
onTabChangeTriggered when switching level tabsindex: number

Liao ICP No. 2025070134