How to add types for global directives | 如何给全局指令添加TS类型? #12510
-
How to add types for global directives? I now use method is to create a interface ComponentCustomProperties {
vPermission: ObjectDirective<
HTMLButtonElement,
PermissionConfig | PermissionConfig['name']
>;
} But when I do that, I run into some problems
但是当我这么做以后会遇到一些问题
Problem 2: <script setup lang="ts">
import { Button } from 'path'
import { ref } from 'vue'
const buttonRef = ref<InstanceType<typeof Button>>()
buttonRef.value.vPermission = {} // Accessible and has TS type hints 可访问且有TS类型提示
</script>
<template>
<Button ref="buttonRef">A Button</Button>
</template>
|
Beta Was this translation helpful? Give feedback.
Answered by
KazariEX
Dec 8, 2024
Replies: 1 comment 1 reply
-
Use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rookie-orange
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
GlobalDirectives
.