e 7 months ago
parent
commit
15fc4758fe

+ 31 - 0
vue/vue初阶/8.样式绑定.html

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <!-- 
+        样式绑定 style
+        v-bind:style="样式"
+        :style=""
+    -->
+    <div id="app">
+        <h1 v-bind:style="{color:colors,width:ww + 'px',height:hh + 'px',backgroundColor:cc}">哈哈哈</h1>
+    </div>
+    <script src="./vue.js"></script>
+    <script>
+        var app = new Vue({
+            el:"#app",
+            data:{
+                colors:"red",
+                ww: 500,
+                hh: 500,
+                cc: 'yellow'
+            }
+
+        })
+    </script>
+</body>
+</html>

+ 44 - 0
vue/vue初阶/9.条件渲染.html

@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <!-- 
+        条件:
+        1. v-if v-else v-else-if
+        2.v-show
+
+        v-if 与 v-show 区别
+        1.v-if 需要符合逻辑性 消耗性呢 ; v-show 符合就执行  不消耗性能
+
+    -->
+    <div id="app">
+        <h1>if判断</h1>
+        <!-- <input type="text"> -->
+        <h3>年龄:{{age}}</h3>        
+        <p v-if="age < 14">小孩</p>
+        <p v-else-if="age> 14 && age <18">青少年</p>
+        <p v-else="age > 18">成年</p>
+        <hr>
+        <h1>show判断</h1>
+        <h3>成绩{{score}}</h3>
+        <p v-show="score >= 90">优秀</p>
+        <p v-show="score >= 75">良好</p>
+        <p v-show="score >= 60">及格</p>
+        <p v-show="score < 60">不及格</p>
+    </div>
+    <script src="./vue.js"></script>
+    <script>
+        var app = new Vue({
+            el:"#app",
+            data:{
+                age: Math.round(Math.random() * 100 - 1 + 1),
+                score: Math.round(Math.random() * 100 - 1 + 1),
+            }
+        })
+    </script>
+</body>
+</html>

+ 5 - 3
vue/vue初阶/1.html → vue/vue初阶/innerHTML与innerText区别.html

@@ -7,14 +7,16 @@
 </head>
 <body>
     <div id="vase">
-        <p id="happy">
+        <h1 id="happy">
             你好
-        </p>
+        </h1>
     </div>
     <script>
-        var content = document.getElementById("happy");
+        var content = document.getElementById("vase");
         alert(content.innerHTML);
+        // innerHTML 解析的是开始标签与结束标签的所有内容
         alert(content.innerText);
+        // innerText 解析的是开始标签与结束标签的中间的文本内容
     </script>
 </body>
 </html>