📜  使用反应钩子表单控制器做出反应选择 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:33.258000             🧑  作者: Mango

代码示例1
function Yourcomponent(props){

    const methods = useForm();
    const { handleSubmit } = methods;
    

    const options = [
     { value: '1', label: 'Apple'},
     { value: '2', label: 'Ball'},
     { value: '3', label: 'Cat'},
    ];
    
    const default_value = 1; // you can replace with your default value
    

    // other codes of the component 
    

    function submitHandler(formData){
    
    // values are available in formData

    }


    return(
      
{* other part of your component *}
{* other part of your form *} (