1234567891011121314151617181920 |
- import { ElMessage } from 'element-plus'
- /**
- * 复制内容到剪贴板
- * @param {string} content 要复制的内容
- * @example
- * getCopy('这是测试文字')
- */
- export function useCopy(content: string) {
- try {
- navigator.clipboard.writeText(content) // 把要复制的内容拷贝到剪贴板
- ElMessage({
- message: '复制成功',
- type: 'success',
- plain: true,
- })
- }
- catch (ex) {
- return false
- }
- }
|