screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Conditionally Enable Disable Button</h3> <select v-model="selectedValue"> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> </select> <button :disabled="isButtonDisabled">Submit</button> </div> <script type="module"> const app = Vue.createApp({ data() { return { selectedValue: '', // Initially no value is selected }; }, computed: { isButtonDisabled() { return this.selectedValue === ''; // Disable the button if no value is selected }, }, }); app.mount('#app'); </script> <style> /* Reset default styles */ * { box-sizing: border-box; margin: 0; padding: 0; } /* Center the app container */ #app { display: flex; flex-direction: column; align-items: center; justify-content: center; } /* Style the heading */ h3 { margin-bottom: 1.5rem; } /* Style the select dropdown */ select { padding: 0.5rem; font-size: 1rem; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 1rem; } /* Style the submit button */ button { padding: 0.5rem 1rem; font-size: 1rem; background-color: #007bff; color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } button:disabled { background-color: #ccc; cursor: not-allowed; } </style> </body> </html>