您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

copyText.web.ts 400B

123456789101112131415161718
  1. import clipboardCopy from 'clipboard-copy';
  2. /**
  3. * Tries to copy a given text to the clipboard.
  4. * Returns true if the action succeeds.
  5. *
  6. * @param {string} textToCopy - Text to be copied.
  7. * @returns {Promise<boolean>}
  8. */
  9. export async function copyText(textToCopy: string) {
  10. try {
  11. await clipboardCopy(textToCopy);
  12. return true;
  13. } catch (e) {
  14. return false;
  15. }
  16. }