From 4c065b033b7779f34c52e972232fac3b04971e5d Mon Sep 17 00:00:00 2001
From: yb <1728066681@qq.com>
Date: Wed, 2 Jun 2021 17:42:28 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=B8=B2=E6=9F=93/=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=B8=B2=E6=9F=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Vue - 2021.06.02.md" | 259 ++++++++++++++++++
1 file changed, 259 insertions(+)
create mode 100644 "\346\242\201\350\211\272\347\274\244/Vue - 2021.06.02.md"
diff --git "a/\346\242\201\350\211\272\347\274\244/Vue - 2021.06.02.md" "b/\346\242\201\350\211\272\347\274\244/Vue - 2021.06.02.md"
new file mode 100644
index 0000000..3b2bba3
--- /dev/null
+++ "b/\346\242\201\350\211\272\347\274\244/Vue - 2021.06.02.md"
@@ -0,0 +1,259 @@
+## Vue.js 第五节课 (条件渲染)
+
+### 条件渲染
+
+1. v-if
+
++ v-if指令就是插入节点或删除节点
+
++ v-if指令可以和v-esle连写
+```
+
+
+ 迷之微笑
+ good nice
+ 土笨笨
+
+
+
梗
+
这是一个梗
+
+
+
+
+```
+```
+ 结果:models值为true全部显示 ok值为false不显示
+```
+```
+ 结果:models值为true显示 梗 值为false显示 这是一个梗
+```
+
+2. v-show
+
++ 注意,v-show 不支持 //template// 元素,也不支持 v-else。
+
++ 当模板属性为true的时候控制台显示为display:block。属性值为false的时候控制台显示display: none
+
+```
+
+
+
+
+```
++ 有条件地跳过循环的执行,那么可以将 v-if 置于外层元素+
+
+```
+
+
+
+
+ lisa为false时全部不显示,Lisa为true时全部显示
+```
+
+ ### 注意:v-if 与 v-for 一起使用
+
+ 1. 永远不要把 v-if 和 v-for 同时用在同一个元素上。
+
+ 2. 当 Vue 处理指令时,v-for 比 v-if 具有更高的优先级
+
+ ### 列表渲染
+
+ + v-for 指令需要使用 item in items 形式的特殊语法,其中 items 是源数据数组,而 item 则是被迭代的数组元素的别名。
+
+ + v-for 支持一个可选的第二个参数
+ ```
+
+
+ -
+ {{ parentMessage }} - {{ index }} - {{ item.message }}
+
+
+
+
+ var example2 = new Vue({
+ el: '#example-2',
+ data: {
+ parentMessage: 'Parent',
+ items: [
+ { message: 'Foo' },
+ { message: 'Bar' }
+ ]
+ }
+})
+ ```
+
+### 维护状态
+
++ 使用 v-for 渲染的元素列表时,它默认使用“就地更新”的策略
+
+### 在组件上使用 v-for
+
++ 任何数据都不会被自动传递到组件里,因为组件有自己独立的作用域。
+
++ 在 元素内只有 - 元素会被看作有效内容
+
+1. 方法一
+```
+
+
+
+```
+
+2. 方法二
+```
+
+
+
+
+```
\ No newline at end of file
--
Gitee