代码之家  ›  专栏  ›  技术社区  ›  user944513

当需要单选按钮时,如何在单击按钮时显示错误

  •  0
  • user944513  · 技术社区  · 7 年前

    我正在使用 react-final-form https://final-form.org/docs/react-final-form/examples 当我点击一个按钮时,我想显示如下图片 enter image description here

    required

    https://codesandbox.io/s/cool-torvalds-lhe9d

    export const renderRadio = field => (
      <SForm.Radio
        checked={field.input.value === field.radioValue}
        label={field.label}
        required={field.required}
        error={field.error && field.touched}
        //error={true}
        name={field.input.name}
        onChange={(e, { checked }) => field.input.onChange(field.radioValue)}
      />
    );
    

    //error={true} hardcorded 它显示了预期的输出。

    但我想要同样的行为在按钮点击

    0 回复  |  直到 7 年前
    推荐文章