From 49ce82caadb0564fa8f346abe3ac33331d72f02f Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 2 Jun 2021 17:38:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Vue=E7=9A=84=E7=AC=AC=E5=85=AD=E6=AC=A1?= =?UTF-8?q?=E8=AF=BE=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note2021-6-02-01.md" | 269 ++++++++++++++++++ .../note2021-6-1-01.md" | 2 +- 2 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 "\346\236\227\351\270\277\351\221\253/note2021-6-02-01.md" diff --git "a/\346\236\227\351\270\277\351\221\253/note2021-6-02-01.md" "b/\346\236\227\351\270\277\351\221\253/note2021-6-02-01.md" new file mode 100644 index 0000000..4482ee2 --- /dev/null +++ "b/\346\236\227\351\270\277\351\221\253/note2021-6-02-01.md" @@ -0,0 +1,269 @@ +# 列表渲染(Vue的第六次课) + +## 用 v-for 把一个数组对应为一组元素 + +我们可以用 v-for 指令基于一个数组来渲染一个列表。v-for 指令需要使用 item in items 形式的特殊语法,其中 items 是源数据数组,而 item 则是被迭代的数组元素的别名。 + +下面给你演示一个例子: + +
+ + + + +
{{index+1}} {{key}} - {{varl}}
+
+ + + + + diff --git "a/\346\236\227\351\270\277\351\221\253/note2021-6-1-01.md" "b/\346\236\227\351\270\277\351\221\253/note2021-6-1-01.md" index 074cd3f..89349ce 100644 --- "a/\346\236\227\351\270\277\351\221\253/note2021-6-1-01.md" +++ "b/\346\236\227\351\270\277\351\221\253/note2021-6-1-01.md" @@ -1,4 +1,4 @@ -# Class 与 Style 绑定 +# Class 与 Style 绑定(Vue的第五次课) ## 绑定 HTML Class -- Gitee From 7e39581b48fdae182c4b5d626a3197467073fce0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 4 Jun 2021 11:37:01 +0800 Subject: [PATCH 2/2] 7 --- .../note2021-6-04-01.md" | 266 ++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 "\346\236\227\351\270\277\351\221\253/note2021-6-04-01.md" diff --git "a/\346\236\227\351\270\277\351\221\253/note2021-6-04-01.md" "b/\346\236\227\351\270\277\351\221\253/note2021-6-04-01.md" new file mode 100644 index 0000000..36844f2 --- /dev/null +++ "b/\346\236\227\351\270\277\351\221\253/note2021-6-04-01.md" @@ -0,0 +1,266 @@ +# 事件处理(Vue的第七次课) + +## 监听事件 + +可以用 v-on 指令监听 DOM 事件,并在触发时运行一些 JavaScript 代码。 + +示例: + +
+ +

The button above has been clicked {{ counter }} times.

+
+ var example1 = new Vue({ + el: '#example-1', + data: { + counter: 0 + } + }) + +结果是一个按钮可以点击,下面是显示点击的次数! + +## 事件处理方法 + +然而许多事件处理逻辑会更为复杂,所以直接把 JavaScript 代码写在 v-on 指令中是不可行的。因此 v-on 还可以接收一个需要调用的方法名称。 + +
+ + +
+ + + +这样会弹出一个弹出框:你好 四肢强,有害水,硫化砷,沪小胖,路网等! + + +## 内联处理器中的方法 + +除了直接绑定到一个方法,也可以在内联 JavaScript 语句中调用方法: + +
+ + +
+ + + +这个方法直接在js语句中调用 + + +有时也需要在内联语句处理器中访问原始的 DOM 事件。可以用特殊变量 $event 把它传入方法: + +
+ +
+ + + +输出了:欢迎来到我的世界,come on ! + +## 事件修饰符 + +在事件处理程序中调用 event.preventDefault() 或 event.stopPropagation() 是非常常见的需求。尽管我们可以在方法中轻松实现这点,但更好的方式是:方法只有纯粹的数据逻辑,而不是去处理 DOM 事件细节。 + +为了解决这个问题,Vue.js 为 v-on 提供了事件修饰符。之前提过,修饰符是由点开头的指令后缀来表示的。 + +.stop +.prevent +.capture +.self +.once +.passive + + + + + +
+ + + + + +
+ + + +
...
+ + + +
...
+使用修饰符时,顺序很重要;相应的代码会以同样的顺序产生。因此,用 v-on:click.prevent.self 会阻止所有的点击,而 v-on:click.self.prevent 只会阻止对元素自身的点击。 + +例子: + +
+
//都输出的话,就是冒泡 + // 当事件绑定这个.stop后,点击该按钮只能输出这一级,不会在向上响应实现 +
+ + + +
+ +