ant-design/components/typography/demo/interactive.md
2019-12-06 12:03:16 +08:00

827 B

order title
3
zh-CN en-US
可交互 Interactive

zh-CN

提供可编辑和可复制等额外的交互能力。

en-US

Provide additional interactive capacity of editable and copyable.

import { Typography } from 'antd';

const { Paragraph } = Typography;

class Demo extends React.Component {
  state = {
    str: 'This is an editable text.',
  };

  onChange = str => {
    console.log('Content change:', str);
    this.setState({ str });
  };

  render() {
    return (
      <div>
        <Paragraph editable={{ onChange: this.onChange }}>{this.state.str}</Paragraph>
        <Paragraph copyable>This is a copyable text.</Paragraph>
        <Paragraph copyable={{ text: 'Hello, Ant Design!' }}>Replace copy text.</Paragraph>
      </div>
    );
  }
}

ReactDOM.render(<Demo />, mountNode);