Last active
August 17, 2022 06:24
-
-
Save andrejsharapov/242bbd365de99cc14b79be66582b18b3 to your computer and use it in GitHub Desktop.
Copy to clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
methods: { | |
async toClipboard() { | |
const textarea = document.querySelector('.code_area textarea'); | |
try { | |
textarea.select(); | |
document.execCommand('copy'); | |
this.$notify({ | |
type: 'success', | |
title: 'Успешно', | |
message: 'Скопировано в буфер обмена', | |
}); | |
} catch (e) { | |
this.$notify({ | |
type: 'error', | |
title: 'Ошибка', | |
message: 'Не удалось скопировать данные', | |
}); | |
} finally { | |
textarea.blur(); | |
} | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment