今天看vue.js示例的时候发现v-model指令绑定input输入框之后,为其绑定了input事件。后来好奇一查MDN,还真有input事件。
The DOM input event is fired synchronously when the value of an <input> or <textarea> element is changed. (For input elements with type=checkbox or type=radio, the input event does not fire when a user clicks the control, because the value attribute does not change.)
Additionally, it fires on contenteditable
editors when its contents are changed.
感觉这和onchange事件类似啊。
后来做了实验,input事件先于onchange发生。