Home > Article > Web Front-end > How to use curly braces in vue
This time I will show you how to use vue’s curly braces. What are the precautions for using vue’s curly braces? The following is a practical case. Let’s take a look. .
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>{{}}的使用</title> <script src="js/vue.js"></script> </head> <body> <p id="container"> <h1>{{msg}}</h1> <h4>{{cart.brand}}</h4> <!--在双花括号中 执行运算表达式 --> <p> 3 + 5 = {{ 3 + 5 }}</p> </p> <script> new Vue({ el:"#container", data:{ msg:"Hello VueJs", cart:{ brand:"Volvo",price:30 } } }) </script> </body> </html>
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>双花括号的练习</title> <script src="js/vue.js"></script> </head> <body> <p> 双花括号:执行表达式,将表达式的结果 输出到当前调用的元素的innerHTML中 </p> <p id="container">{{msg}} <h4>三目运算3>5:{{3>5?"对":"错"}}</h4> <h4>逻辑运算3>5 && 2>1:{{3>5 && 2>1}}</h4> <h4>{{!hasMore}}</h4> <h4>{{totalNum>count?"大于":"小于"}}</h4> </p> <script> new Vue({ el:"#container", data:{ msg:"Hello VueJs", count:3, totalNum:10, hasMore:true } }) </script> </body> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of SPA single-page application in vueVue-router components pass parameters to each other methodThe above is the detailed content of How to use curly braces in vue. For more information, please follow other related articles on the PHP Chinese website!