From 983b9f1537c33d1a31b7f2bd5b04f7ddfa3d267a Mon Sep 17 00:00:00 2001 From: xiaoyou <2232705454@qq.com> Date: Tue, 1 Jun 2021 10:48:26 +0800 Subject: [PATCH] =?UTF-8?q?class=E4=B8=8Estyle=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2021-06-01-vue.md" | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 "\346\270\270\346\265\267\346\236\227/2021-06-01-vue.md" diff --git "a/\346\270\270\346\265\267\346\236\227/2021-06-01-vue.md" "b/\346\270\270\346\265\267\346\236\227/2021-06-01-vue.md" new file mode 100644 index 0000000..91bc610 --- /dev/null +++ "b/\346\270\270\346\265\267\346\236\227/2021-06-01-vue.md" @@ -0,0 +1,78 @@ +# Class与style绑定 + + +### 对象语法 + +我们可以传给 v-bind:class 一个对象,以动态地切换 class: +``` +
+``` +``` + + +``` ++ 对象语法也就是在v-bind:class绑定一个对象的时候,里面的值将影响最终取值, ++ 比如如果 这里isActive的值为true 则会被渲染成class='active' 如果为false , 则 不会存在. ++ 一般情况 {A:xx ,B:xx}的写法是json格式写法,只能以key/value的形式被识别,而不会像例子中一样直接被处理,如果value的值为true则,key绑定在class里面 + + +### 数组语法 + + ++ 数组语法 ++ 我们可以把一个数组传给 v-bind:class ,以应用一个 class 列表: +``` +