本文介绍了React复制到剪贴板可以使用插件copy-to-clipboard,分享给大家,具体如下:
安装
使用
CopyToClipboard
<input value={this.state.value} size={10} onChange={this.onChange} />
<CopyToClipboard text={this.state.value} onCopy={this.onCopy}>
<span>Copy to clipboard with span</span>
</CopyToClipboard>
<CopyToClipboard text={this.state.value} onCopy={this.onCopy}>
<button>Copy to clipboard with button</button>
</CopyToClipboard>
{this.state.copied ? <span style={{color: 'red'}}>Copied.</span> : null}
@H_<a href="/tag/502/" target="_blank" class="keywords">502</a>_28@
<textarea style={{marginTop: '1em'}} cols="22" rows="3" />
const appRoot = document.createElement('div');
appRoot.id = 'app';
document.body.appendChild(appRoot);
ReactDOM.render(