Solution to the problem of two-way binding failure between angular and vue

        I believe that many people have such a habit, that is, they like to write the form validation of input restrictions in the input box in html

angular

view

Just like the above (restricted to only enter numbers), this way of writing is generally difficult to find in the development process, even in testing, we know that both angular2.0 and vue2.0 pass Object.definePropety It is realized by the data hijacking of the getter and setter of (), if the regular is written in the html tag, when you switch to the Chinese input method, it will cause the two-way binding to fail, that is, when inputting English characters and other characters , the input box is empty, but the bound data is there. I encountered this kind of bug in the process of development before. At that time, I didn't measure it, and the test didn't measure it. Finally, the online user found it. Yes, very embarrassing time, in fact, the solution is very simple, that is, don't write the regex in the html tag

The same is true for vue; in this way, there will be no problem of two-way binding failure. Finally, I hope that everyone should not write regular expressions in html tags during development.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326312548&siteId=291194637