React-Intl How to use FormattedMessage in input placeholder

前端 未结 11 631
走了就别回头了
走了就别回头了 2020-12-13 03:20

I\'m unsure how to get the values from


into a placeholder format like input:<

11条回答
  •  旧巷少年郎
    2020-12-13 04:21

    Like this:

    import React, {PropTypes} from 'react';
    import { injectIntl, FormattedMessage } from 'react-intl';
     
    /**
    * {
    * "hello": "Hello",
    * "world": "World"
    * }
    */
     
    // pure function
    const PureFunciton = injectIntl(({ intl }) => {
    return (
      

    {intl.formatMessage({ id: 'hello' })}

    ) });   // class Component class componentName extends Component { handleStr = () => { // return 'Hello'; const { intl } = this.props; return intl.formatMessage({ id: 'hello' }) } render() { return (

    {this.handleStr()}

    ); } }   export default injectIntl(connect(componentName));

提交回复
热议问题