The @ input event in version 2.4 of vue is different from that in version 2.5.

same code, < input type= "text" v Melody model = "aa" @ input= "aa = aa.replace (/\ DMag,"")" >

version 2.5 will still instantly display the input and then match it, while 2.4 will not show the matching content

Mar.28,2021

what a coincidence! I happen to be writing the article Vue Source Code Reading-batch Asynchronous updates and nextTick principles , which happens to involve the content of this piece ~

.

this situation is also annotated in the source code of vue. You can click in and have a look, so the version after 2.5 has changed this situation. I will translate it here:

.
in versions prior to 2.4, nextTick was basically based on microtask, but in some cases microtask has too high priority
and may be triggered between successive sequential events (for example, # 4521 , # 6690 ) or even during event bubbling of the same event ( # 6566 ).
but if all of them are changed to macrotask, it will also have a performance impact on some scenes with redrawing and animation, such as issue-sharp6813.
the workaround prov
ided here is to use microtask, by default but to force the use of macrotask when needed (for example, in event handlers attached to v-on)

so it will not be displayed before 2.4because of the dom event previously implemented using microtask, which is executed before patch after the macro task execution of the current tick, so I guess it is because the microtask high priority reason does not wait for the current tick change patch to render to the real dom has changed the data, so of course it will not be rendered to the real DOM.

the nextTick after 2.5 uses macrotask, as a callback that is sure to be executed after the next tick, so the content entered by the input will naturally be rendered to the real dom before the callback is executed, so what you see is a flash ~


so? What's your problem? Shouldn't you look at the source code and analyze the reasons?

and don't write this. If you bind < input > to aa , you should

.
data() {
  return {
    _aa: '',
  }
},
computed: {
  aa: {
    get() {
      return this._aa;
    },
    set(value) {
      this._aa = value.replace(/\D/g, '');
    }
  }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a5ce-2b56e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a5ce-2b56e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?