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