Clearing input in vuejs form

后端 未结 7 2221
Happy的楠姐
Happy的楠姐 2020-12-14 09:06

Just completed a todolist tutorial. When submitting the form the input field doesn\'t clear.

After trying both:

    document.getElementById(\"todo-         


        
相关标签:
7条回答
  • 2020-12-14 09:43

    These solutions are good but if you want to go for less work then you can use $refs

    <form ref="anyName" @submit="submitForm">
    </form>
    
    <script>
       methods: {
          submitForm(){
             // Your form submission
             this.$refs.anyName.reset(); // This will clear that form
          }
       }
    </script>
    
    0 讨论(0)
提交回复
热议问题