Vue: 关于 form 的 reset 功能

Created on 11 Aug 2016  ·  3Comments  ·  Source: vuejs/vue

在 form 中使用 <button type="reset">rest</button>
浏览器在清空 input 等表单的 value 的时候,观察 vue 中的 data 未响应此变化。

作为浏览器的基础行为,是否可以考虑在 reset 后,也将表单上附加的 v-model 的 data 给 reset 掉?

Most helpful comment

You can write a directive that listens to the reset event and finds and triggers input & change on every input element inside the form.

All 3 comments

Hi!

Please follow the Issue Reporting Guidelines. Make sure to ask questions on the forums or the gitter chat. We keep questions out of issues :smile:

About the question, you can handle the reset event like this. Hope this helps!

thanks, I konw that way can handle the reset event, but can not auto rest v-model

You can write a directive that listens to the reset event and finds and triggers input & change on every input element inside the form.

Was this page helpful?
0 / 5 - 0 ratings