File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ With Vue 3.5 and `@vue/language-tools` 2.1 (powering both the IDE language servi
376
376
In cases where auto-inference is not possible, you can still cast the template ref to an explicit type via the generic argument:
377
377
378
378
``` ts
379
- const el = useTemplateRef <HTMLInputElement >(null )
379
+ const el = useTemplateRef <HTMLInputElement >(' el ' )
380
380
```
381
381
382
382
<details >
@@ -438,7 +438,7 @@ In cases where the exact type of the component isn't available or isn't importan
438
438
import { useTemplateRef } from ' vue'
439
439
import type { ComponentPublicInstance } from ' vue'
440
440
441
- const child = useTemplateRef <ComponentPublicInstance | null >( null )
441
+ const child = useTemplateRef <ComponentPublicInstance >( ' child ' )
442
442
```
443
443
444
444
In cases where the component referenced is a [ generic component] ( /guide/typescript/overview.html#generic-components ) , for instance ` MyGenericModal ` :
@@ -467,7 +467,7 @@ import { useTemplateRef } from 'vue'
467
467
import MyGenericModal from './MyGenericModal.vue'
468
468
import type { ComponentExposed } from 'vue-component-type-helpers'
469
469
470
- const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>(null )
470
+ const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>('modal' )
471
471
472
472
const openModal = () => {
473
473
modal.value?.open('newValue')
You can’t perform that action at this time.
0 commit comments