Yi 3 anos atrás
pai
commit
1d6e255f1e
7 arquivos alterados com 46 adições e 24 exclusões
  1. 0 24
      3-6/index.html
  2. 0 0
      demo/.gitgnore
  3. 0 0
      demo/3-5/index.html
  4. 46 0
      demo/3-6/index.html
  5. 0 0
      demo/README.md
  6. 0 0
      demo/index.html
  7. 0 0
      demo/vue.js

+ 0 - 24
3-6/index.html

@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>Vue中的样式绑定</title>
-    <script src="../vue.js"></script>
-</head>
-<body>
-  <div id="app">
-    <div @click="handleDivClick" :class="{activated: isActivated}">Hello world</div>
-  </div>
-  <script>
-    var vm = new Vue({
-      el: "#app",
-      data: {
-        handleDivClick: function (){
-
-        }
-      }
-    })
-  </script>
-
-</body>
-</html>

+ 0 - 0
.gitgnore → demo/.gitgnore


+ 0 - 0
3-5/index.html → demo/3-5/index.html


+ 46 - 0
demo/3-6/index.html

@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Vue中的样式绑定</title>
+    <script src="../vue.js"></script>
+    <style>
+      .activated {
+        color: #f40808;
+      }
+      .activated-one {
+        color: #000000;
+      }
+    </style>
+</head>
+<body>
+  <div id="app">
+    <div 
+      @click="handleDivClick" :class="[activated]"
+    >
+      Hello world
+    </div>
+    <div :style="styleObj" @click="handleDivClick">
+      China
+    </div>
+  </div>
+  <script>
+    var vm = new Vue({
+      el: "#app",
+      data: {
+        activated: "",
+          styleObj: {
+            color: "black"
+          }
+      },
+      methods: {
+        handleDivClick: function (){
+            this.activated = this.activated === "activated" ? "" : "activated"
+            this.styleObj.color = this.styleObj.color === "black" ? "red":"black"
+        }
+      }
+    })
+  </script>
+
+</body>
+</html>

+ 0 - 0
README.md → demo/README.md


+ 0 - 0
index.html → demo/index.html


+ 0 - 0
vue.js → demo/vue.js