Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@uiw/react-copy-to-clipboard
Advanced tools
Readme
将文本到剪切板,复制到剪贴板功能可以应用于各种元素,基于 @uiwjs/copy-to-clipboard 封装。
import { CopyToClipboard } from 'uiw';
// or
import CopyToClipboard from '@uiw/react-copy-to-clipboard';
import React from 'react';
import { CopyToClipboard } from 'uiw';
class Demo extends React.Component {
constructor() {
super();
this.state = {
message: ''
}
}
render() {
return (
<div>
<CopyToClipboard
text="我被一个连接复制了!"
onClick={() => {
this.setState({ message: '复制成功!你可以粘贴了。' }, () => {
setTimeout(() => {
this.setState({ message: '' });
}, 2000);
});
}}
>
点击我复制
</CopyToClipboard>
<div style={{color: '#28a745'}}>{this.state.message}</div>
</div>
)
}
}
export default Demo;
import React from 'react';
import { CopyToClipboard, Input, Button } from 'uiw';
class Demo extends React.Component {
constructor(props){
super(props);
this.state = {
copyText: "生亦何欢,死亦何苦"
};
this.input = React.createRef();
}
onChange(e){
// this.setState({
// copyText: e.target.value
// })
}
render() {
const { copyText } = this.state;
return (
<div>
<div>
<Input
type="text"
ref={this.input}
value={copyText}
onChange={this.onChange.bind(this)}
/>
</div>
<CopyToClipboard
style={{ marginTop:10, display:'inline-block' }}
text={copyText}
onClick={() => {
// 复制提示
this.setState({ message: '复制成功!你可以粘贴了。' }, () => {
setTimeout(() => {
this.setState({ message: '' });
}, 2000);
});
this.input.current.select();
}}
>
<Button type="primary">点击复制</Button>
<span style={{color: '#28a745'}}>{this.state.message}</span>
</CopyToClipboard>
</div>
)
}
}
export default Demo;
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
text | 拷贝的文本 | String | - |
onClick | 点击事件 | Function(text,isCopy,event) | - |
FAQs
CpyToClipboard component
The npm package @uiw/react-copy-to-clipboard receives a total of 224 weekly downloads. As such, @uiw/react-copy-to-clipboard popularity was classified as not popular.
We found that @uiw/react-copy-to-clipboard demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.