8000 [RFC] useClipboard · Issue #2715 · alibaba/hooks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[RFC] useClipboard #2715

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

Open
Majmunu opened this issue Jan 6, 2025 · 1 comment
Open

[RFC] useClipboard #2715

Majmunu opened this issue Jan 6, 2025 · 1 comment

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

@crazylxr
Copy link
Collaborator

可以的,这个挺常用的,欢迎 PR

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

2 participants
0