screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h2>Vue Js write/create text to file</h2> <textarea v-model="fileContent" rows="5" cols="40"></textarea> <button @click="generateAndDownloadFile">Generate File</button> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { fileContent: 'To create a text file, simply click on the button below after reading the following text ', }; }, methods: { generateAndDownloadFile() { const blob = new Blob([this.fileContent], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.setAttribute('download', 'file.txt'); document.body.appendChild(link); link.click(); document.body.removeChild(link); }, }, }); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; margin-top: 50px; } h2 { font-size: 24px; margin-bottom: 20px; } textarea { width: 300px; height: 150px; margin-bottom: 20px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; resize: vertical; } button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } button:hover { background-color: #45a049; } </style> </body> </html>