screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <!-- Load Vuetify Icon and Styles --> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.9.55/css/materialdesignicons.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vuetify@3.1.11/dist/vuetify.min.css"> </head> <body> <div id="app"> <!-- Create Vuetify App --> <v-app> <v-main> <v-container> <h3>Vuetify clear input field after submit</h3> <v-form ref="myForm" @submit.prevent="submitForm"> <v-text-field v-model="inputValue" label="Input Field" :rules="inputRules"></v-text-field> <v-btn type="submit">Submit</v-btn> </v-form> </v-container> </v-main> </v-app> </div> <!-- Load Vue.js and Vuetify script --> <script src="https://unpkg.com/vue@3.2.21/dist/vue.global.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify@3.1.11/dist/vuetify.min.js"></script> <!-- Create Vue.js and Vuetify app --> <script type="module"> const { createApp } = Vue const { createVuetify } = Vuetify const vuetify = createVuetify() const app = createApp({ data() { return { inputValue: '', inputRules: [ (value) => !!value || 'Input is required', (value) => (value && value.length <= 10) || 'Input must be less than 10 characters' ] } }, methods: { async submitForm() { const { valid } = await this.$refs.myForm.validate() if (valid) { alert('Form is valid') this.$refs.myForm.reset() this.$refs.myForm.resetValidation() } }, } }).use(vuetify).mount('#app'); // Mount the app to the #app element </script> </body> </html>