Specify options through options. See the example code for usage.
浏览器不支持,请手动复制 options.en.vue
<template><div>
{{ data }}
<np-formv-model="data":option="option"/></div></template><scriptsetuplang="ts">import type { FormOption }from'naive-plus'import{ ref }from'vue'const data =ref({})constoption: FormOption ={onSubmit:async()=>awaitnewPromise<void>(resolve=>setTimeout(()=>resolve(),1200)),columns:[{label:'Gender',key:'gender',type:'radio',defaultValue:'man',options:[{label:'Male',value:'man'},{label:'Female',value:'woman'},],},{label:'Hobby',key:'hobby',type:'select',options:form=>
form.gender ==='man'?['Sing','Dance','Rap']:['Piano','Dance'],},{label:'Hobbies (multiple)',key:'hobbyArray',type:'checkbox',options:asyncform=>{// simulate fetching data from the backendconstfetch=(gender: string)=>{returnnewPromise<any[]>(resolve=>{setTimeout(()=>{resolve(
gender ==='man'?['Sing','Dance','Rap']:['Piano','Dance'])},600)})}returnawaitfetch(form.gender)},},],}</script>