Difference between the input button and submit, inputbuttonsubmit
Story:
In fact, this problem has been encountered yesterday, but yesterday it was an old employee of the company who helped me the intern, and I did (guess) decide (test) the old employee did not know the difference. Then we encountered the same problem today.
Synopsis:
Now I am working on a project in the company and use the AngularJs framework. My boss gave me an interface service and called and tested it. After I deployed the project package on the local tomcat server, start to write the front-end code, from html to css to JavaScript (rarely used) to bootstrap. Now the static front-end interface is built up. Then we use the interface service provided by the boss for testing. angularJS is an MVVM framework, typically two-way binding. After writing the relevant logic Code, every time the interface jumps to itself, in my code, if response returns true, it should jump to the order interface, and false, it will jump to the login interface. In short, it is really strange not to jump to myself! Then I opened chrome's developer tool and found that the Angular function is not written every time. Later, I checked that ng-model was okay, and found that the input type was submit. I tried to change it to a button. Hey, everything was okay. I was puzzled by this, so I wrote this essay to find out the truth.
Story truth:
In general, both input and button can be used as buttons to submit data to the backend for backend processing.
Difference: ① the input is input, but after type = "submit", it also plays the role of submission, so the input is a submission form.
<Input type = "submit" value = "submit">
② A button is a pure button. If you do not add an operation on the button, you can only add a type = "submit" onclick = "xxx ().
<Button type = "submit"> OK </button>
Therefore, according to the principle of single responsibility in the software design model, we recommend that you use a button as the button, instead of the input button as the submit button, and the input button should be used as the data input.
The above content comes from an intern's understanding of the front-end. If this is not the case, check whether you can point it out. Thank you!