模板语法.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>模板语法</title>
  8. <script type="Text/javascript" src="../js/vue.js"></script>
  9. </head>
  10. <body>
  11. <!--
  12. 1、插值语法:
  13. 1、功能:用于解析标签体内容,也就是起始标签和结束标签中间的内容
  14. 2、语法: {{xxx}} ,xxxx 会作为 js 表达式解析
  15. 2、指令语法:
  16. 1、功能:用于解析标签(包括解析标签属性、解析标签体内容、绑定事件……)
  17. 2、举例:v-bind:href = 'xxxx' 或简写为 :href=“xxxx”,xxxx 同样要写js 表达式
  18. 3、说明:Vue 中有有很多的指令,且形式都是v-????,此处只是用 v-bind 举个例子
  19. -->
  20. <!-- 准备好一个容器 -->
  21. <div id="root">
  22. <h1>插值语法</h1>
  23. <h3>你好,{{name}}</h3>
  24. <hr>
  25. <h1>指令语法</h1>
  26. <a v-bind:href="school.url">点击前往百度{{school.name}}</a>
  27. <a :href="school.url.toUpperCase()">点击前往百度2{{school.name}}</a>
  28. </div>
  29. </body>
  30. <script type="Text/javascript">
  31. Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示
  32. new Vue({
  33. el:"#root",
  34. data:{
  35. name:'jack',
  36. school:{
  37. name:'尚硅谷',
  38. url:'https://www.baidu.com'
  39. }
  40. }
  41. })
  42. </script>
  43. </html>