Introduction
v-bind and {{}} can bind data, but there is a difference between the two. v-bind is not good. Why is v-bind bad? It is because v-bin made a complete replacement mistake. If you want to splice strings, then v-bind is not a good choice. Let’s see the example below.
Here comes the code segment
For example, we have such a requirement. We define a variable a and a variable b and calculate the value of the variable a*b to display it.
It’s so easy for me to go there. I’m so embarrassed to write Jianshu. Go home and farm! Ha ha.
The output style we want is (a*b)=>a*b For example: (3*4)=>12
<div ng-app="" ng-init="a=3;b=4"> <input type="text" ng-model="a"/>*<input type="text" ng-model="b" /> =<span v-bind="a*b">turn out:</span> </div>
This method will replace the text on the entire span label and the result will only show 12
<div ng-app="" ng-init="a=3;b=4"> <input type="text" ng-model="a"/>*<input type="text" ng-model="b"/> =<span>({{a}}*{{b}}=>{{a*b}})<span/> </div>
So try to use {{}} when doing development.
Summarize
The above is the AngularJs template and v-bind introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!