在vue自定义指令directives中获取this指针

木头的喵喵拖孩
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<template>
<div v-my-custom-directive></div>
</template>

<script>
export default {
directives: {
myCustomDirective: {
inserted(el, binding, vnode) {
let that = vnode.context; // 在此处获取this指针
},
},
},
};
</script>
  • 标题: 在vue自定义指令directives中获取this指针
  • 作者: 木头的喵喵拖孩
  • 创建于: 2024-04-16 15:33:45
  • 更新于: 2024-05-21 10:56:15
  • 链接: https://blog.xx-xx.top/2024/04/16/在vue自定义指令directives中获取this指针/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
此页目录
在vue自定义指令directives中获取this指针