Vue.Js Reset Form Fields
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> <form id="form"><br> <input v-model="name" name="name" type="text" placeholder='Name' /><br> <input v-model="email" name="email" type="email" placeholder='Email' /><br> <input v-model="phone" name="phone" type="phone" placeholder='Phone' /><br> <button @click='resetForm'>reset</button> </form> </div> <script> new Vue({ el: '#app', data: { email: '', name: '', phone = ''; }, methods:{ resetForm: function () { this.email = ''; this.name = ''; this.phone = ''; } } }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> <form id="form"><br> <input v-model="name" name="name" type="text" placeholder='Name' /><br> <input v-model="email" name="email" type="email" placeholder='Email' /><br> <input v-model="phone" name="phone" type="phone" placeholder='Phone' /><br> <button @click='resetForm'>reset</button> </form> </div> <script> new Vue({ el: '#app', data: { email: '', name: '', phone = ''; }, methods:{ resetForm: function () { this.email = ''; this.name = ''; this.phone = ''; } } }); </script> </body> </html>
Copyrights@tutorialsplane.com