点击按钮复制

使用 navigator 提供的剪贴板能力复制

 

export const useCopy = async (str: string) => {
    try {
        await navigator.clipboard.writeText(str)
        console.log('复制成功')
    } catch (e) {
        console.log('复制失败')
    }
}

  

posted @ 2022-11-08 23:06  yuhui_yin  阅读(26)  评论(0编辑  收藏  举报