Day9 Methods and v-on

今天来介绍这个指令v-on用来绑定HTML DOM,来触发要执行的事件

Method
https://ithelp.ithome.com.tw/upload/images/20210923/20140076xNJCI59IlP.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076qaNNoDHbwJ.png
这时并没有执行action,并不会触发method,所以会出现未执行
https://ithelp.ithome.com.tw/upload/images/20210923/20140076UPOYloPrc8.png
当我主动触发时才会执行action,所以会出现执行了

V-on

  • 缩写 : @
  • 修饰符
  • .stop : 停止触发外层DOM事件
  • .prevent : 停止浏览器预设行为
  • .capture : 加入.capture修饰符的DOM将会优先触发
  • .self : 只触发自己范围内的事件,不包含子元素
  • .once : 加入.once修饰符的事件,仅能触发一次
  • .passive : 加上.passive就一定可以触发网页,无视prevent功能
    详细的用法会在下一篇介绍

事件处理(Event Handling)
Methods这个属性经常会搭配指令v-on绑定使用,所以当触发click就会执行action,并显示执行了
https://ithelp.ithome.com.tw/upload/images/20210923/201400766N4WkWq54H.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076EEN2O4fmG9.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076XQE2Zi3ZQ3.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076cGeorDBFMi.png

使用物件 Object {key: value}
Key : 像要绑定的事件名称
Value : 呼叫名称
https://ithelp.ithome.com.tw/upload/images/20210923/201400765UkEoxQVao.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076DE28dOz56q.png
https://ithelp.ithome.com.tw/upload/images/20210923/201400764UxrmPzRlL.png
https://ithelp.ithome.com.tw/upload/images/20210923/20140076VstMsqHPAu.png

资料来源:
https://v1.vuejs.org/guide/events.html
https://cythilya.github.io/2017/04/17/vue-methods-and-event-handling/
https://yuhantaiwan.coderbridge.io/tags/Vue/
https://vuejs.org/v2/api/#methods


<<:  Day23:Greedy Algorithm - 贪婪演算法

>>:  Day08-流量限制(三)

【Day 20】 实作 - 於 AWS Quicksight 建立 Sankey diagram 以及设定 Action

昨天我们已经透过 AWS Glue Job 来调整 Partition 分区结构以及将此格式转换成 ...

DAY26 - 网站分析工具介绍 - 质化与量化的结合 - Matomo

昨天介绍完以搜集质化数据为强项的Hotjar之後,今天我们要介绍的是可以搜集质化和量化的工具 - M...

Venom 2 在线

Venom 2 在线 《毒液2:屠杀开始》由哥伦比亚电影公司、漫威影业等联合出品,安迪·瑟金斯执导,...

AE极光制作2-Day8

接续昨天的练习:https://ithelp.ithome.com.tw/articles/1026...

Day2 理解 golang slice 用法及原理 II

续上篇 Day1 理解 golang slice 用法及原理 I 什麽是 slice 是的容量 (c...