用户点击一个按钮,它将向容器组件发送道具
handleCopyNote = () => {
this.props.handleCopyNote();
}
容器组件选择并复制文本
handleCopyNote = () => {
let range = document.createRange();
range.selectNode(this.noteRef.current); <--- React Ref
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
}
正在选择文本,但未复制。用document.getElementById(id)