【问题标题】:Integrate react-intl with react-table将 react-intl 与 react-table 集成
【发布时间】:2021-02-15 16:02:55
【问题描述】:

我在整个应用程序中使用react-intl 进行翻译。我现在正在尝试通过以下方式使用react-table 将翻译后的消息用作表的标题:

    {
    Header: <FormattedMessage id="users.user" defaultMessage="User" />,
    accessor: 'role',
},

但我收到以下错误消息:

×

错误:需要列 ID(或字符串访问器)!

【问题讨论】:

    标签: javascript reactjs react-table react-intl


    【解决方案1】:

    您可以尝试改用intl.formatMessage API。

    【讨论】:

      【解决方案2】:

      只需添加 像这样的对象的 id 元素:

      {
       Header: <FormattedMessage id="users.user" defaultMessage="User" />,
       id:'h1', //<--------------
      accessor: 'role',
      },
      

      【讨论】:

        猜你喜欢
        • 2019-06-24
        • 2019-02-15
        • 2021-07-22
        • 2021-09-15
        • 1970-01-01
        • 1970-01-01
        • 2020-09-06
        • 2020-01-26
        • 2019-12-25
        相关资源
        最近更新 更多