Skip to content

Commit a989239

Browse files
docs: correct usage examples of useTemplateRef (#3031) (#2423)
Co-authored-by: Damian Głowala <[email protected]>
1 parent 9e7ba45 commit a989239

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/typescript/composition-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ Vue 3.5 と `@vue/language-tools` 2.1(IDE の言語サービスと `vue-tsc`
376376
自動推論が不可能な場合でも、ジェネリック引数を使用してテンプレート参照を明示的な型にキャストすることができます:
377377

378378
```ts
379-
const el = useTemplateRef<HTMLInputElement>(null)
379+
const el = useTemplateRef<HTMLInputElement>('el')
380380
```
381381

382382
<details>
@@ -438,7 +438,7 @@ const compRef = useTemplateRef<FooType | BarType>('comp')
438438
import { useTemplateRef } from 'vue'
439439
import type { ComponentPublicInstance } from 'vue'
440440

441-
const child = useTemplateRef<ComponentPublicInstance | null>(null)
441+
const child = useTemplateRef<ComponentPublicInstance>('child')
442442
```
443443

444444
参照されるコンポーネントが[ジェネリックコンポーネント](/guide/typescript/overview.html#generic-components)の場合、例えば `MyGenericModal` の場合:
@@ -467,7 +467,7 @@ import { useTemplateRef } from 'vue'
467467
import MyGenericModal from './MyGenericModal.vue'
468468
import type { ComponentExposed } from 'vue-component-type-helpers'
469469
470-
const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>(null)
470+
const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>('modal')
471471
472472
const openModal = () => {
473473
modal.value?.open('newValue')

0 commit comments

Comments
 (0)