Component_Select.md

February 5, 2025 · View on GitHub

XNSelect

This component is based on the NSelect component of Naive-UI.


Usage

For more details, please refer to the Demo.

Template Style:

Notes: Since this is just a syntax sugar for the options property (there will be a certain performance loss), so that you can't compose XNSelectOption and XNSelectOptionGroup with other elements.

<template>
  <x-n-select>
    <x-n-select-option value="1">Option A</x-n-select-option>
    <x-n-select-option value="2">Option B</x-n-select-option>
    <x-n-select-option value="3">Option C</x-n-select-option>
  </x-n-select>
</template>

Scoped Slots:

<script setup>
  const options = [
    { value: '1', label: 'A' },
    { value: '2', label: 'B' },
    { value: '3', label: 'C' }
  ];
</script>
<template>
  <x-n-select :options="options">
    <template #render-label="{ option }">
      <div>{{ 'Option ' + option.label }}</div>
    </template>
  </x-n-select>
</template>

API

XNSelect Props:

For other props, please see Naive-UI documentation.

XNSelect Slots:

NameTypeDescriptionVersion
defaultThe content inside select.0.2.0
render-label{ option, label, value, selected }Custom option label.0.2.0
render-option{ node, option, selected }Custom option node.0.2.0
render-tag{ option, close }Custom tag.0.2.0

For other slots, please see Naive-UI documentation

XNSelect Methods:

NameTypeDescriptionVersion
getData() => { options: Array }Get data.0.7.0

For other methods, please see Naive-UI documentation.

XNSelectOption Props:

NameTypeDefaultDescriptionVersion
labelstringLabel of the option.0.7.0
valuestring | numberValue of the option.0.7.0
disabledbooleanfalseWhether to disable the option.0.7.0

XNSelectOption Slots:

NameTypeDescriptionVersion
defaultCustom displayed label.0.7.0

XNSelectOptionGroup Props:

NameTypeDefaultDescriptionVersion
labelstringLabel of the group.0.7.0

XNSelectOptionGroup Slots:

NameTypeDescriptionVersion
defaultThe content inside group.0.7.0
labelCustom displayed label.0.7.0