Vue-------自定义指令

html部分:

<el-button type="primary" v-lxt="asd" round>主要按钮</el-button>

js:

注意:js要小写v+首字母大写,自定义事件里面一定要有生命周期哦

const vLxt = {
  created(el, binding, vnode, prevVnode) {
    el.addEventListener('click', function () {
      console.log(2143353);
    })
    console.log(el, 1);
    console.log(binding, 2);
    console.log(vnode, 3);
    console.log(prevVnode, 4);
  },
  // 在元素被插入到 DOM 前调用
  beforeMount() { },
  // 在绑定元素的父组件
  // 及他自己的所有子节点都挂载完成后调用
  mounted() { },
  // 绑定元素的父组件更新前调用
  beforeUpdate() { },
  // 在绑定元素的父组件
  // 及他自己的所有子节点都更新后调用
  updated() { },
  // 绑定元素的父组件卸载前调用
  beforeUnmount() { },
  // 绑定元素的父组件卸载后调用
  unmounted() { },
}

ヾ( ̄▽ ̄)Bye~Bye~

相关推荐

  1. Vue定义指令

    2024-04-03 20:06:03       46 阅读
  2. Vue定义指令

    2024-04-03 20:06:03       48 阅读
  3. Vue-------定义指令

    2024-04-03 20:06:03       38 阅读
  4. Vue定义指令

    2024-04-03 20:06:03       29 阅读
  5. vue定义指令

    2024-04-03 20:06:03       21 阅读
  6. (详解)Vue定义指令

    2024-04-03 20:06:03       65 阅读
  7. vue3定义指令

    2024-04-03 20:06:03       64 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-03 20:06:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-03 20:06:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-03 20:06:03       82 阅读
  4. Python语言-面向对象

    2024-04-03 20:06:03       91 阅读

热门阅读

  1. git diff

    2024-04-03 20:06:03       37 阅读
  2. linux ldd依赖拷贝

    2024-04-03 20:06:03       40 阅读
  3. LeetCode 36

    2024-04-03 20:06:03       35 阅读
  4. U3D开发中Json管理器的常用思路

    2024-04-03 20:06:03       36 阅读
  5. MySQL面试题系列-2

    2024-04-03 20:06:03       36 阅读
  6. Mysql中的那些索引

    2024-04-03 20:06:03       40 阅读
  7. c++ 死锁检测与内存泄露

    2024-04-03 20:06:03       28 阅读
  8. 自定义注解实现对实体类的字段进行校验

    2024-04-03 20:06:03       37 阅读
  9. Redis入门--头歌实验Redis基本命令

    2024-04-03 20:06:03       30 阅读
  10. Android:身份证识别功能实现

    2024-04-03 20:06:03       34 阅读
  11. rk平台Android12屏幕永不休眠

    2024-04-03 20:06:03       29 阅读