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"> <h1>Vue js convert username and passpwrd to base64</h1> <h2>Login Form</h2> <form @submit.prevent="submitForm"> <label for="username">Username:</label> <input type="text" id="username" v-model="username"> <br> <label for="password">Password:</label> <input type="password" id="password" v-model="password"> <br> <button type="submit">Submit</button> <p v-if="result">Base64 string: {{result}}</p> </form> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { username: 'admin', password: 'password', result: '' }; }, methods: { submitForm() { const base64Credentials = btoa(`${this.username}:${this.password}`); this.result = base64Credentials // You can now use the base64Credentials variable to send the encoded credentials to the server } } }) </script> <style scoped> /* Center the content */ #app { display: flex; flex-direction: column; align-items: center; } /* Style the heading tags */ h1, h2 { text-align: center; font-weight: normal; } h1 { font-size: 2rem; } h2 { margin-top: 2rem; font-size: 1.5rem; } /* Style the form */ form { margin-top: 2rem; display: flex; flex-direction: column; align-items: center; } label { font-size: 1.2rem; } input[type="text"], input[type="password"] { padding: 0.5rem; border: 2px solid #ccc; border-radius: 4px; margin-bottom: 1rem; font-size: 1.2rem; } button[type="submit"] { background-color: #4CAF50; color: white; padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; font-size: 1.2rem; } button[type="submit"]:hover { background-color: #3e8e41; } </style> </body> </html>