screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h2>Vue Js Cut And Paste Text</h2> <div id="app"> <input type="text" v-model="text"> <button @click="cutText">Cut</button> <button @click="pasteText" :disabled="isClipboardEmpty">Paste</button> </div> <script> new Vue({ el: '#app', data() { return { text: 'Vue Js Cut And Paste Functionality', isClipboardEmpty: true }; }, methods: { cutText() { // Copy the text to the clipboard navigator.clipboard.writeText(this.text); // Clear the input field this.text = ''; // Set isClipboardEmpty to false this.isClipboardEmpty = false; }, async pasteText() { // Get the pasted text from the clipboard const pastedText = await navigator.clipboard.readText(); // Append the pasted text to the input field this.text += pastedText; // Set isClipboardEmpty to false if there is text in the clipboard this.isClipboardEmpty = pastedText.trim() === ''; }, }, }); </script> <style scoped> input[type="text"] { padding: 10px; font-size: 18px; border: 2px solid #ccc; border-radius: 5px; margin-right: 10px; } button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } button:active { background-color: #2980B9; } button:disabled { background-color: #cccccc; cursor: not-allowed; } </style> </body> </html>