np-radio Radio Group

A wrapper around n-radio-group that adds async option support and supports button-group style.

Basic Usage

Specify options through options, and bind the value with v-model.

浏览器不支持,请手动复制 basic.en.vue

Button Group

Set button to use the button-group style.

浏览器不支持,请手动复制 button-group.en.vue

Async Options

The options prop supports an async function, e.g. for fetching dictionaries from a backend API.

浏览器不支持,请手动复制 async.en.vue

Async Computed Options

The options prop supports an async computed function, e.g. for fetching different dictionaries from different APIs based on the type.

浏览器不支持,请手动复制 computed.en.vue

Custom Field Names

Usually options are fetched from a backend, and the data structure is not always {label, value}. You can use label-field and value-field to specify option field names.

浏览器不支持,请手动复制 keys.en.vue

Change Event

Get the value change via the change event.

浏览器不支持,请手动复制 change.en.vue

Component Configuration

Props

PropDescriptionTypeDefault
v-modelSelected valueRadioGroupValue-
optionsOptionsAsyncValue<RadioOption[]>-
label-fieldCustom label field namestringlabel
value-fieldCustom value field namestringvalue
buttonWhether to use button-group stylebooleanfalse
loadingDelayLoading delay in ms, effective when options is asyncnumber250
propsNRadioGroup propsNRadioGroup Propsopen in new window-
onChangeChange event(value: RadioGroupValue) => void-

Events

EventDescriptionCallback
update:modelValueValue change event(value: RadioGroupValue) => void
changeChange event(value: RadioGroupValue) => void

Types

The component exports the following type definitions:

import type { NpRadioProps } from 'naive-plus'