File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -479,9 +479,9 @@ const openModal = () => {
479479
480480请注意在 ` @vue/language-tools ` 2.1 以上版本中,静态模板 ref 的类型可以被自动推导,上述这些仅在极端情况下需要。
481481
482- ## Typing Global Custom Directives {#typing-global-custom-directives}
482+ ## 为自定义全局指令添加类型 {#typing-global-custom-directives}
483483
484- In order to get type hints and type checking for global custom directives declared with ` app.directive() ` , you can extend ` ComponentCustomProperties `
484+ 可以通过扩展 ` ComponentCustomProperties ` 来为使用 ` app.directive() ` 声明的全局自定义指令获取类型提示和类型检查
485485
486486``` ts [src/directives/highlight.ts]
487487import type { Directive } from ' vue'
@@ -490,7 +490,7 @@ export type HighlightDirective = Directive<HTMLElement, string>
490490
491491declare module ' vue' {
492492 export interface ComponentCustomProperties {
493- // prefix with v (v-highlight)
493+ // 使用 v 作为前缀 (v-highlight)
494494 vHighlight: HighlightDirective
495495 }
496496}
@@ -504,12 +504,12 @@ export default {
504504
505505``` ts [main.ts]
506506import highlight from ' ./directives/highlight'
507- // ...other code
507+ // ...其它代码
508508const app = createApp (App )
509509app .directive (' highlight' , highlight )
510510```
511511
512- Usage in component
512+ 在组件中使用
513513
514514``` vue [App.vue]
515515<template>
You can’t perform that action at this time.
0 commit comments