簡體   English   中英

為 DeleteWithConfirmButton react-admin 設置自定義消息

[英]Set custom message for DeleteWithConfirmButton react-admin

我怎樣才能將我的消息發送到 DeleteWithConfirmButton 不是全局的,而是只發送給一個?

我可以全局更改消息:

const messages = {
  en: {
    ra: {
      message: {
        delete_contents: 'HELLO?'
      }
    }
  }
};

const i18nProvider = locale => messages[locale];

 <Admin
    i18nProvider={i18nProvider}

delete_content: '您確定要刪除此項目嗎?', - 默認消息

DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
classes: PropTypes.object,
className: PropTypes.string,
crudDelete: PropTypes.func.isRequired,
label: PropTypes.string,
record: PropTypes.object,
redirect: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.bool,
    PropTypes.func,
]),
resource: PropTypes.string.isRequired,
translate: PropTypes.func,
icon: PropTypes.element,
};

在當前版本的 React-admin 中,DeleteButton / BulkDeleteButton 組件具有 confirmTitle / confirmContent 屬性,用於設置自定義 header 和對話框內容:

DeleteWithConfirmButton.propTypes = {
    basePath: PropTypes.string,
    classes: PropTypes.object,
    className: PropTypes.string,
    
    confirmTitle: PropTypes.string,       
    confirmContent: PropTypes.string,
    
    label: PropTypes.string,
    record: PropTypes.any,
    redirect: PropTypes.oneOfType([
        PropTypes.string,
        PropTypes.bool,
        PropTypes.func,
    ]),
    resource: PropTypes.string,
    icon: PropTypes.element,
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM