Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] useClipboard #2715

Open
Majmunu opened this issue Jan 6, 2025 · 0 comments
Open

[RFC] useClipboard #2715

Majmunu opened this issue Jan 6, 2025 · 0 comments

Comments

@Majmunu
Copy link

Majmunu commented Jan 6, 2025

Demo

const { copyToClipboard, pasteFromClipboard } = useClipboard();
// 复制操作
  const handleCopy =async () => {
    const displayText = "React 对象111"; // 外部显示的文本
    const dataToCopy = { name: "React 对象", value: 123, description: "这是一个测试对象" }; // 要存储的数据
    await copyToClipboard(displayText, dataToCopy);
  };

  // 粘贴操作
  const handlePaste = async () => {
    const data = await pasteFromClipboard();
    setPastedData(data);
  };

获取粘贴板数据
image

在非项目粘贴显示内容
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant