Home > Web Front-end > JS Tutorial > body text

How to use curly braces in vue

php中世界最好的语言
Release: 2018-04-14 17:37:29
Original
5639 people have browsed it

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>
Copy after login

Code:
<!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>
Copy after login

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 vue


Vue-router components pass parameters to each other method


The 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!