uni-app 事件

// 事件映射表,左侧为 WEB 事件,右侧为 ``uni-app`` 对应事件
{
    click: 'tap',//点击
    touchstart: 'touchstart',//手指开始在元素上触屏
    touchmove: 'touchmove',//移动
    touchcancel: 'touchcancel',//取消
    touchend: 'touchend',
    tap: 'tap',//单机
    longtap: 'longtap', //推荐使用longpress代替 长按
    input: 'input', //输入
    change: 'change',//改变
    submit: 'submit',
    blur: 'blur',//失焦
    focus: 'focus',
    reset: 'reset',//表单重置
    confirm: 'confirm',//确认
    columnchange: 'columnchange',//字段变化
    linechange: 'linechange',//行变化
    error: 'error',//错误
    scrolltoupper: 'scrolltoupper',//滚动到顶部
    scrolltolower: 'scrolltolower',//滚动到最小面
    scroll: 'scroll'//滚动的时候
}


注意:

  • 为兼容各端,事件需使用 v-on 或 @ 的方式绑定,请勿使用小程序端的bind 和 catch 进行事件绑定。
  • 在input和textare中change事件会被转换为blur事件
  • 事件修饰符
    • .stop:各平台均支持, 使用时会阻止事件冒泡,在非 H5 端同时也会阻止事件的默认行为
    • .prevent 仅在 H5 平台支持
    • .self:仅在 H5 平台支持
    • .once:仅在 H5 平台支持
    • .capture:仅在 H5 平台支持
    • .passive:仅在 H5 平台支持
  • 若需要禁止蒙版下的页面滚动,可使用 @touchmove.stop.prevent="moveHandle",moveHandle 可以用来处理 touchmove 的事件,也可以是一个空函数。
    <view class="mask" @touchmove.stop.prevent="moveHandle"></view>
  • 按键修饰符:uni-app运行在手机端,没有键盘事件,所以不支持按键修饰符。
 
原文地址:https://www.cnblogs.com/lxz-blogs/p/12575949.html