在 Ant Design 中更改模态按钮文本

wra*_*ger 1 reactjs antd

我有Modal默认按钮文本。我需要改变他们,但okButtonProps.childrencancelButtonProps.children不起作用。

<Modal
  okButtonProps={{
    children: "Custom OK"
  }}
  cancelButtonProps={{
    children: "Custom cancel"
  }}
>
  Modal content
</Modal>
Run Code Online (Sandbox Code Playgroud)

代码沙盒

yur*_*uri 7

你必须使用okTextcancelText财产:

    <Modal
      visible={true}
      okButtonProps={{
        children: "Custom OK"
      }}
      cancelButtonProps={{
        children: "Custom cancel"
      }}
      okText="Hello"
      cancelText="Ciao"
    />
Run Code Online (Sandbox Code Playgroud)

okButtonProps并且cancelButtonProps是放置按下按钮或按下按钮props后将发生的动作。okcancel

它们不是用于放置文本,而是用于放置动作。

要放置文本使用okTextand cancelText,只需检查 API:

https://ant.design/components/modal/#API