关于vue自定义指令的更新

bind --> beforeMount 指令绑定到元素后发生。只发生一次
inserted --> mounted 元素插入到父DOM后发生
beforeUpdate: Vue3.x新添加的,这是在元素更新之前调用,
componentUpdated --> updated
beforeUnmount : Vue3.x新添加的,将在卸载元素前调用
unbind --> unmounted

const MyDirective = {
  created(el, binding, vnode, prevVnode) {}, // 新增
  beforeMount() {},
  mounted() {},
  beforeUpdate() {}, // 新增
  updated() {},
  beforeUnmount() {}, // 新增
  unmounted() {}
}
posted @ 2022-09-22 18:10  肖越  阅读(221)  评论(0)    收藏  举报