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"> <button @click="openModal">Open Modal</button> <div v-if="showModal" class="modal"> <div class="modal-content"> <form @submit.prevent="submitForm"> <h3>Vue Js Close Modal after form submit</h3> <!-- Form fields here --> <button type="submit">Submit</button> </form> </div> </div> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { showModal: false }; }, methods: { openModal() { this.showModal = true; }, closeModal() { this.showModal = false; }, submitForm() { // Perform form submission logic here // Close the modal after form submission this.closeModal(); } } }); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; justify-content: center; } .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; } .modal-content { background-color: white; padding: 20px; border-radius: 10px; } form { display: flex; flex-direction: column; align-items: center; } input { padding: 10px; margin-bottom: 10px; border: none; border-radius: 5px; } button { padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } </style> </body> </html>